Re: Re: Call to object function, want to PHP interpret returned string

From: Date: Mon, 06 Jul 2009 09:38:40 +0000
Subject: Re: Re: Call to object function, want to PHP interpret returned string
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-294933@lists.php.net to get a copy of this message
David Robley wrote:
John Allsopp wrote:
Hi At the top of a webpage I have: <?php include_once("furniture.php"); $myFurniture = new furniture(); echo $myFurniture->getTop("my company title"); ?> to deliver the first lines of HTML, everything in HEAD and the first bits of page furniture (menu, etc). In the furniture object in getTop(), I want to return a string that includes the CSS file that I call with an include_once. But the include_once isn't interpreted by PHP, it's just outputted. So from:
        $toReturn = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0
Transitional//EN' ........
            <?php
                include_once('styles3.txt');
            ?>
            .......";
        return $toReturn;
I get <?php include_once('styles3.txt'); ?> in my code. Do I really have to break up my echo $myFurniture->getTop("my company title"); call to getTopTop, then include my CSS, then call getTopBottom, or can I get PHP to interpret that text that came back? PS. I may be stupid, this may be obvious .. I don't program PHP every day Thanks in advance for your help :-) Cheers J
    
First guess is that your page doing the including doesn't have a filename with a .php extension, and your server is set to only parse php in files with a .php extension. Cheers Ah, thanks. It's a PHP object returning a string, I guess the PHP interpreter won't see that.
So, maybe my object has to write a file that my calling file then includes after the object function call. Doesn't sound too elegant, but is that how it's gotta be? Cheers J

« previous php.general (#294933) next »