Jump to content


Photo

php code doesn't work


  • Please log in to reply
3 replies to this topic

#1 shams

shams
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 27 March 2006 - 02:48 AM

hi,
as i read from manual all of these codes should work:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
echo 'This is a test';
?>

<?php echo 'This is a test' ?>

<?php echo 'We omitted the last closing tag';
</body>
</html>
but it doesn't worked for me unless i complette all the missing tags and semi colons, any idea please?

#2 micah1701

micah1701
  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 27 March 2006 - 03:28 AM

i'm not sure what the problem is?

its not supposed to work if you don't use the right colans and closing tags.

if you leave them out, PHP can't parse your code and can't display the page. so make sure you put the semi colans in the right place and remember to close your tags.

"Confidence in the face of risk."

#3 Guest_footballkid4_*

Guest_footballkid4_*
  • Guests

Posted 27 March 2006 - 05:12 AM

1) Next time, please choose a topic that is somewhat relevant to the content of the post, such as "PHP code not evaluated". That title would tell us that your code isn't being processed at all...where as saying it just doesn't work can mean a lot of things.

2) Are you able to get any content from PHP displayed on a page? If yes, then the problem you're looking at is the incorrect use of syntax. PHP requires correct syntax so it can parse your code and find where one line ends and the next begins. If you can't get any data to display, please create a topic in the "PHP Installation" forum with more details about your server.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 March 2006 - 10:34 AM

Your code is working it is because of your last PHP statement:
<?php echo 'We omitted the last closing tag';
</body>
</html>
You haven't ended your PHP statement properly and I dont know here you have heard that from about PHP not needing a closing PHP statement tag (?>) as PHP needs this in order to know here each code block ends, as currently PHP is returning the following error:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: syntax error, unexpected '<' in {path/of/file/here/filename.php} on line 13[/quote]You dont see this message as your server may have display_errors turned off in your php.ini file and so you get a blank page. I would recommend you to turn on display_errors this will help understand why your scripts aren't working if an error occurs.

The other two PHP statements are valid. However dont use the the secound PHP statement too much make sure you do allways end you lines of code with a semi-colon. So in order to get your script to work just delete this: <?php echo 'We omitted the last closing tag'; from your script.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users