[solved] Debug PHP in HTML file |
Veteran
|
By default, a web server will parse only files with a .php (or .php4, .php5, etc.) extension as PHP. Files with .htm or .html extensions are seen as HTML and are not pushed through the PHP parser.
The easiest way around this is to rename your files to have .php extensions. You can still make the file content pure HTML if you wish. However, the point is that any PHP code in such files will be parsed correctly. Another way would be to set up your web server to parse all files with .htm and .html extensions as PHP. But that is probably not a good idea as it would be "expensive" to unnecessarily parse all your HTML files that have no PHP content. |
||||||||||||
_________________ |
|
.
|
||||||||||||
Last edited by mife on Mon Oct 27, 2008 2:17 am; edited 1 time in total |
|
Thank you for the reply anno.
There are some good reasons to let the webserver execute php in html files. To please Google and meet the expectations of users and my customers and pages have to be html. Imagine you are a web programmer like me and a customer ask you to add functionalty to an existing page. If you are asked just to add functionalty, change nothing else my answer would be not "NO, can't be done". Yours? Another point is to hide as much as possible from malicious minds. Wasn't php desigend exactly for that purpose, to write php in html? Is it uncommon to do so? How do cms or template systems work other than that? So once again - is it possible for phped to reckon php code in a html file? If not a simple no would be sufficient instead of asking me to switch my profession or change my customers |
||||||||||||
|
|
erm, it is possible as I've done it.
Ah, erm, actually, thinking about it, no I haven't! I do have a few HTML files that the server treats as PHP files (via the htaccess script, it changes the handler for a specific file), but they're all stubs which call php files to generate the content. i.e. I have an index.htm file which has basically one line it in, which is include index.php. Putting PHP code inside HTML files can be done and the server will see it as PHP code, but the debugger won't see it as a PHP file and whilst you can step through it, you won't get the normal execution point bar etc.., so you won't know which line is being run. Its probably more of a phpEd problem than debugger problem. The other option is to rename the html file to php when debugging and then change it back. Or do as I do, have the htm file but put the code into a PHP file and simply include it into the HTM file. Then you can set your breakpoints in the php file. Hope you find that more useful Just thought of something else, I haven't tried it, so its just an idea - you may have already tried it anyway. In the Settings screen in phpEd, click on the Associations item on the left and move the .htm / .html (whichever you need) association from HTML files to PHP4/5 files and see if that fools phpEd into loading it in debugger mode... |
||||||||||||
_________________ Regards Steve. |
Re: PHP in HTML file |
|
Isn't the answer to save your file as *.phtml? I find that the most convenient solution fo my uses. Regards Will |
||||||||||||||
|
|
Hi,
MGSteve, your tipp done the trick! Tools: Settings: File Associations: Add desired extension to php and restart phped Thanks very much to everybody who tried to help. Regards |
||||||||||||
|
[solved] Debug PHP in HTML file |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by