Jump to content

Recommended Posts

Hi all, is it the browser which could not recognize my PHP code or is it my settings which are wrong? Currently I am using PHP5 and apache 2.2x. I have follow the settings in the book, but still it looks like the browser does not recognize my php code. When I code a simple php test program, the browser would treat the <?php and ?> as a string and output as a string in the browser.

 

here is my test code

 

<html>

<head>

<title>PHP Test</title>

</head>

<body>

<p>This is an HTML line</p>

< ?php

echo “This is a PHP line”;

 

? >

</body>

</html>

 

-----------------------------------------------------------------------------

Browser output this

-----------------------------------------------------------------------------

 

This is an HTML line

< ?php echo “This is a PHP line”; ? >

 

Link to comment
https://forums.phpfreaks.com/topic/192691-browser-cant-reconginze-php-code/
Share on other sites

A) You have spaces as part of both your opening and closing php tags. They should be <?php and ?>

B) PHP is a server-side scripting language. It is parsed, tokenized, and interpreted on the web server when the page is requested by the browser and the browser just receives any output that is produced. You should be browsing to the file using a URL something like http://localhost/your_file.php

Browser DOES NOT process php code. SERVER does. For client-side scripting, use Javascript. To see that page as working php script:

 

1. rename file from .html to .php,

2. put that page in htdoc folder on server

3. start your server

4. access page from browser using localhost/your-page.php instead of file path

 

If you have problem with setting server up, try xampp.

 

Goat

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.