Page 1 of 1

PHP Constants Need Help

Posted: Sat Jul 30, 2011 7:53 pm
by michaelli321
I am learning PHP and im learning PHP Constants. On my webpage it says
Parse error: syntax error, unexpected '>' in C:\Inetpub\vhosts\tagslash.com\httpdocs\constants.php on line 14

I dont know what to do. this is my code:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Constants</title>
</head>
<body>
<?php # Script 1.9 - constants.php

// Set today's date as a constant:
define ('TODAY', 'August 28, 2007);

// Print a message, using predefined constants and the TODAY constant:
echo '<p>Today is ' . TODAY . '.<br />This server is running version <b>' . PHP_VERSION . '</b> of PHP on the <b>' . PHP_OS . '</b> operating system.</p>';

?>
</body>
</html>

Re: PHP Constants Need Help

Posted: Sat Jul 30, 2011 8:00 pm
by califdon
You are missing the closing single quote (') at the end of your date:
define ('TODAY', 'August 28, 2007);
should be:
define ('TODAY', 'August 28, 2007');

Without that closing quote, PHP thinks that everything that follows is part of the quoted string until it gets to another single quote.