RE: [PHP] Parse Error... how to fix?

From: Date: Thu, 16 Dec 2004 18:19:43 +0000
Subject: RE: [PHP] Parse Error... how to fix?
Groups: php.general 
Request: Send a blank email to php-general+get-204519@lists.php.net to get a copy of this message
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 16 December 2004 17:39, GH wrote: > Hi All... > Got a problem... here is the error: Parse error: parse error, > expecting T_STRING' or T_VARIABLE' or > `T_NUM_STRING' in > /var/www/html/ahrc_computerclub/ahrc_computerclub.php on line 42... I > am not sure on how to fix it... > > line 42 is: "<TITLE> $language['program_name'] </TITLE>\n" > . "<TITLE> {$language['program_name']} </TITLE>\n" . But: > > function printHeader(){ > echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 > Transitional//EN\"\n" . > > "\"http://www.w3.org/TR/REC-html40/loose.dtd\"><HTML>\n" > . > "<HEAD>\n" . > "<meta name=\"description\" content=\"\" >\n" . > "<meta name=\"author\" content=\"Gary H\">\n" . > "<meta name=\"keywords\" content=\"\" >\n" . > "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n" . > "<TITLE> $language['program_name'] </TITLE>\n" . > "</HEAD>\n". > "<BODY>\n"; This is messy and somewhat unreadable. I would suggest either a heredoc: function printHeader(){ echo <<<HEAD <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN http://www.w3.org/TR/REC-html40/loose.dtd\"> <HTML> <HEAD> <meta name="description" content="" > <meta name="author" content="Gary H"> <meta name="keywords" content="" > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE> {$language['program_name']} </TITLE> </HEAD> <BODY> HEAD; } or escaping from PHP into raw HTML: function printHeader(){ ?> <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN http://www.w3.org/TR/REC-html40/loose.dtd\"> <HTML> <HEAD> <meta name="description" content="" > <meta name="author" content="Gary H"> <meta name="keywords" content="" > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE> <?php echo $language['program_name'] ?> </TITLE> </HEAD> <BODY> <?php }

« previous php.general (#204519) next »