Jump to content

Archived

This topic is now archived and is closed to further replies.

shams

php code doesn't work

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest footballkid4
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 [b]syntax[/b]. 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.

Share this post


Link to post
Share on other sites
Your code is working it is because of your last PHP statement:
[code]<?php echo 'We omitted the last closing tag';
</body>
</html>[/code]
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: [i]<?php echo 'We omitted the last closing tag';[/i] from your script.

Share this post


Link to post
Share on other sites

×

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.