kenji82 Posted February 20, 2010 Share Posted February 20, 2010 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”; ? > Quote Link to comment https://forums.phpfreaks.com/topic/192691-browser-cant-reconginze-php-code/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 20, 2010 Share Posted February 20, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/192691-browser-cant-reconginze-php-code/#findComment-1015092 Share on other sites More sharing options...
Goat Posted February 20, 2010 Share Posted February 20, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/192691-browser-cant-reconginze-php-code/#findComment-1015093 Share on other sites More sharing options...
kenji82 Posted February 20, 2010 Author Share Posted February 20, 2010 Thanks alot for the help provided, I just realize that there is a syntax error on the open and close quote that I used directly from the E-book to test out the php. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/192691-browser-cant-reconginze-php-code/#findComment-1015112 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.