dazwalker Posted November 24, 2007 Share Posted November 24, 2007 I have just installed apache 2.0.59 win 32 X86 and PHP 5.2.5 I have tried some basic php code and saved it as a php file, but when I open the file in Internet Explorer it only reads the html and not the php code. I used the code below: <HTML> <HEAD> <TITLE> My first PHP page</TITLE> </HEAD> <BODY> <? echo "Hello world!"; ?> </BODY> </HTML> Whats wrong? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 24, 2007 Share Posted November 24, 2007 Probably a problem with short open tags - <? Always use full php open tags - <?php to make your code portable between servers with different settings. Quote Link to comment Share on other sites More sharing options...
dazwalker Posted November 24, 2007 Author Share Posted November 24, 2007 Brilliant this did the trick, thank you. Quote Link to comment Share on other sites More sharing options...
AtomicNetwork Posted November 24, 2007 Share Posted November 24, 2007 If you so wish you can enable short tags within the php.ini file. If you have full root access to the server, the php.ini can be found in the following locations: Windows: C:/php/ (default) Linux: /usr/lib/php.ini (Most Linux Distrobutions) If it is not located at the above directory on linux, you can find the file by typing the following command into terminal locate php.ini (you may have to update the file database first, which can be done by typing "updatedb") You can then edit the file using nano, vi, or pico depending on the server distrobution. Regards. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 25, 2007 Share Posted November 25, 2007 That would result in code that is not portable between servers, in case you might not have the ability to turn on short open tags. Most people don't like to write code twice, once on a development system and again when they put it on a different server. The following is the recommendation by php.net - ; NOTE: Using short tags should be avoided when developing applications or ; libraries that are meant for redistribution, or deployment on PHP ; servers which are not under your control, because short tags may not ; be supported on the target server. For portable, redistributable code, ; be sure not to use short tags. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.