Jump to content

php code not recognised?


dazwalker

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.