[vox-tech] PHP Include File Problem

Troy Arnold vox-tech@lists.lugod.org
Mon, 9 Dec 2002 15:10:26 -0800


Two options:
One, include your xml declaration as a quoted string:
echo '<?xml version="1.0"?>';

Or, disable php's short_open_tags ( <? ?> vs. <?php ?> )
Try sticking this in a .htaccess:
php_flag short_open_tag off

You might also be able to toggle that flag on a page by page basis with
something like: <?php ini_set('short_open_tag','off'); ?>

hth
-ta

On Mon, Dec 09, 2002 at 02:46:04PM -0800, Jim Angstadt wrote:
> Hi All,
> 
> I just started to learn PHP and need help with 
> an include file. Below are 3 test files.
> 
> The 4th line of html_header, ie. the xml declaration,
> creates a parse error:
> 
>    parse error in [snip]/html_header.php on line 4
>    
> When the line is removed, no parse error and the page 
> displays with all vars populated properly.
> 
> Somehow I need to escape those pesky characters or ???
> 
> RedHat 7.2, PHP 4.0.6, Mozilla 0.9
> 
> Thanks,
> Jim
> 
> 
> # ---------- include.php, called from browser
> <?php
> 
> $css_ref	= "../africa_loc.css";
> $h1		= "Sample H One Heading";
> $h2		= "An H Two Heading";
> $footer_subject	= "$h1, $h2";
> $home_page	= "http://jima9.tripod.com/fam/index.html";
> 
> include("html_header.php");
> html_header_10_strict( $css_ref, $h1, $h2 );
> 
> include("html_footer");
> ?>
> # ----------
> 
> 
> # ---------- html_header.php, called from include.php
> <?php
> function html_header_10_strict ( $css_ref, $h1, $h2 )
> {
> ?>
> <?xml version="1.0"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
> Strict//EN"
>   
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta name="robots" content = "noindex, nofollow" />
> <meta http-equiv="Content-Type" content="text/html;
> charset=ISO-8859-1" />
> 
> <link rel="stylesheet" type="text/css" href="<?php
> echo "$css_ref"; ?>" />
> <meta name="keywords" content="one, " />
> <title><?php echo "$h1"; ?></title>
> </head>
> 
> <body lang="en">
> <div class="pane">
> <h1><?php echo "$h1"; ?></h1>
> <h2><?php echo "$h2"; ?></h2>
> <?php
> }
> ?>
> # ---------- 
> 
> 
> # ---------- html_footer, called from include.php
> </div>
> 
> <p class="footer">
> Please report errors, typos, or problems to <a href= 
> "mailto:jimajima9@yahoo.com?subject = <?php echo
> "$footer_subject"; ?>">
> jimajima9@yahoo.com</a><br />
> Visit the <a href="<?php echo "$home_page"; ?>">home
> page</a> of this site.
> </p>
> 
> </body></html>
> # ----------
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech