|
Posted by Jerry Stuckle on 05/17/07 12:46
Ming wrote:
> Hi folks,
>
> I have a php file, it contains just a few php codes. The php codes I
> need to use is to construct an object, and use it several times, from
> html head until the last line of html code.
>
> I know I can construct the same object (I am using php5) several
> times, something like $object = new $class, and use several <?php
> $object->functionX ?> ... <?php $object->functionZ ?> to include
> php code in html code.
>
> However, to construct this object I have to call a remote server, and
> rely on its response, which is a bit slow. To construct it several
> times takes even more time, and I do not like that.
>
> So my questions are :
>
> 1) How can I embed a big chunk of html code in php without using
> something like echo "<a href=\"aaa.html\">" all the time
>
> 2) Can I just construct an object one time and use it in different <?
> php ... ?> blocks?
>
> Thanks,
>
Ming,
You can go in and out of PHP at any time, i.e.
.... header info ...
<html>
Lots of html code here
<?php
// Put a bunch of PHP in here
?>
More and more html
<?php
// Some more PHP
?>
</html>
You can also use heredoc syntax
<(http://us2.php.net/manual/en/language.types.string.php)>, i.e.
<?php
echo <<EOT
Now is the time
for all good men
to come to the aid
of their party.
EOT
?>
And yes, you can use the same object in as many PHP blocks as you want,
as long as it's on the same page. Objects do not disappear when you
leave a PHP block; rather they go away at the end of the page.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|