<?php blabla.... ?> or <? blabla.... ?>

Show us the code that is causing the error.

That’s called “[short tags][1]”, and they are disabled by default with an option in php.ini in some setups.

I’ve recently hit a strange problem where a server wouldn’t interpret the whole website and just spit out unprocessed code, while happily running my little one-line phpinfo.php from the very same directory with the same file permissions. The short tags were simply not enabled on this system, and the whole site was coded with just <? (surely, that spared us a huge share traffic in transferring the site to server, but the whole team was bummed).

So, if you use just the <?, that’s ok, but then make sure that the target server has the short_open_tag=On in its php.ini, or else your site will send out raw unprocessed php code with for no obvious reason.
[1]: http://php.net/manual/en/language.basic-syntax.phptags.php

Sorry for the late reply.
Here is the code I am having trouble with

<html>
<head>
	<title>Testing Footer.PHP</title>
</head>
<body>
nxacewjgj45oij3m
<?php
&copy; 2010- echo date("Y");
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
?>

</body>
</html>

The line with nxacewjgj45oij3m is just random characters.
The url for this code is enter link description here

There is an error:

Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in/home/petalsan/public_html/testingfooter.php on line 1

Try remming the following line:

// &copy; 2010- echo date("Y");

// New bit
echo '<br />';
echo '&copy;';
echo '<br />';
echo  2010 - date("Y");
echo '<br />';

I always use <?php for normal PHP and <?= to echo within HTML. As others have said short tags are disabled by default now and using <?php means that if you code ever finds itself somewhere where using short tags are not an option you have nothing to worry about. <?php and <?= will always work (PHP 5.4 or later).

@Tigers Looks to me like this is all that’s needed:

<?php echo '&copy; 2010–' . date("Y"); ?>

Or, if you do want the whole lot, something like this:

<?php echo '&copy; 2010–' . date("Y") . '<br>' .
'Today is ' . date("Y/m/d") . '<br>' .
'Today is ' . date("Y.m.d") . '<br>' .
'Today is ' . date("Y-m-d") . '<br>' .
'Today is ' . date("l");
?>

or also like this:

<?php echo '&copy; 2010–', date("Y"), '<br>',
'Today is ', date("Y/m/d"), '<br>',
'Today is ', date("Y.m.d"), '<br>',
'Today is ', date("Y-m-d"), '<br>',
'Today is ', date("l");
?>

Et al :smile:
Thank you for all your help. I now have that bit working well.
On to my next step.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.