Jump to content

php code doesn't work


shams

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?
Link to comment
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.
Link to comment
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.
Link to comment
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.
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.