I have main site to which i put code using require function, but when i add php functions into it, they appear as plain text. The php code is rather long so i won't paste it here. Could anyone help me with that?
Thanks
ok i am adding some code:
require part with onl开发者_开发技巧y one function:
<?php
$content=<<<EOF
echo 'hello';
EOF;
require 'whatever.php';
?>
and main part:
<?php
echo <<<CONT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
...
</head>
<body id="body">
<div id="container">
$content
</div>
<div id="add_func">
</div>
</body>
</html>
CONT;
?>
Make sure that You wrap your code in <?php.....?>
tags.
Update:
No need to use the heredoc syntax for what you are doing, you could modify you code like this:
<?php
echo 'hello';
require 'whatever.php';
?>
And:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
...
</head>
<body id="body">
<div id="container">
<?php echo $content; ?>
</div>
<div id="add_func">
</div>
</body>
</html>
just get rid of heredoc
require part
<?php
echo 'hello';
require 'whatever.php';
?>
main part
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
...
</head>
<body id="body">
<div id="container">
<?php echo $content ?>
</div>
<div id="add_func">
</div>
</body>
</html>
that's all
PHP is not Perl, heredoc is useless here, even if properly used.
Just never use this ugly syntax.
精彩评论