RE: Parse Error... how to fix?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux