PHP Constants Need Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
michaelli321
Forum Newbie
Posts: 7
Joined: Fri Jul 29, 2011 11:18 pm

PHP Constants Need Help

Post 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>
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: PHP Constants Need Help

Post 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.
Post Reply