ob_start <> eval?

This is a discussion on ob_start <> eval? within the PHP General forums, part of the PHP Programming Forums category; I have a template system that takes some data, scrubs it and then with a load method includes the required ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-05-2007
blackwater dev
 
Posts: n/a
Default ob_start <> eval?

I have a template system that takes some data, scrubs it and then with a
load method includes the required template. I need to add a param so it
doesn't simply include but returns the contents of the template in a string
with all of the vars populated. I tried:

ob_start();
include my template
$template=ob_get_contents();
ob_clean();
return $template;

But this returns the template it's it's raw for with all of tha
<?=$whatever?> tags. Can I fill these in and still pass as another var
without using eval()?

What do other template systems to do return a template as a string on load?


Thanks!

Reply With Quote
  #2 (permalink)  
Old 07-06-2007
Larry Garfield
 
Posts: n/a
Default Re: [PHP] ob_start <> eval?

If I understand what you're doing correctly, then it should work and I've done
it many times. First thing you should do, though, is switch from short tags
to proper tags, <?php echo $whatever; ?>. If you have short tags disabled,
it will not parse <?= syntax.

On Thursday 05 July 2007, blackwater dev wrote:
> I have a template system that takes some data, scrubs it and then with a
> load method includes the required template. I need to add a param so it
> doesn't simply include but returns the contents of the template in a string
> with all of the vars populated. I tried:
>
> ob_start();
> include my template
> $template=ob_get_contents();
> ob_clean();
> return $template;
>
> But this returns the template it's it's raw for with all of tha
> <?=$whatever?> tags. Can I fill these in and still pass as another var
> without using eval()?
>
> What do other template systems to do return a template as a string on load?
>
>
> Thanks!



--
Larry Garfield AIM: LOLG42
larry@garfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
Reply With Quote
  #3 (permalink)  
Old 07-06-2007
blackwater dev
 
Posts: n/a
Default Re: [PHP] ob_start <> eval?

We have short tags enabled as our templates work fine with them.

Thanks!

On 7/5/07, Larry Garfield <larry@garfieldtech.com> wrote:
>
> If I understand what you're doing correctly, then it should work and I've
> done
> it many times. First thing you should do, though, is switch from short
> tags
> to proper tags, <?php echo $whatever; ?>. If you have short tags
> disabled,
> it will not parse <?= syntax.
>
> On Thursday 05 July 2007, blackwater dev wrote:
> > I have a template system that takes some data, scrubs it and then with a
> > load method includes the required template. I need to add a param so it
> > doesn't simply include but returns the contents of the template in a

> string
> > with all of the vars populated. I tried:
> >
> > ob_start();
> > include my template
> > $template=ob_get_contents();
> > ob_clean();
> > return $template;
> >
> > But this returns the template it's it's raw for with all of tha
> > <?=$whatever?> tags. Can I fill these in and still pass as another var
> > without using eval()?
> >
> > What do other template systems to do return a template as a string on

> load?
> >
> >
> > Thanks!

>
>
> --
> Larry Garfield AIM: LOLG42
> larry@garfieldtech.com ICQ: 6817012
>
> "If nature has made any one thing less susceptible than all others of
> exclusive property, it is the action of the thinking power called an idea,
> which an individual may exclusively possess as long as he keeps it to
> himself; but the moment it is divulged, it forces itself into the
> possession
> of every one, and the receiver cannot dispossess himself of it." --
> Thomas
> Jefferson
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Reply With Quote
  #4 (permalink)  
Old 07-06-2007
Kaleb Pomeroy
 
Posts: n/a
Default Loading a URL


/*I am trying to load an XML file from the following site, which btw is a working site you can put in the address bar.*/
$url = "http://isbndb.com/api/books.xml?access_key=WC2BD24W&results=prices&index 1=isbn&value1=030681496x";
//open the url
if(!($handle = fopen($url, "r"))){
echo "Error opening URL <br />".$url;
exit();
}
else{
echo "It Worked";
//actually use simpleXML and parse it, but that's not the problem.
}

/*
*For some reason that code returns:
*Error opening URL
*http://isbndb.com/api/books.xml?acce...ue1=030681496x
*Is there something obvious that I am missing, or what?
*/

Reply With Quote
  #5 (permalink)  
Old 07-06-2007
Robert Cummings
 
Posts: n/a
Default Re: [PHP] Loading a URL

On Thu, 2007-07-05 at 20:39 -0500, Kaleb Pomeroy wrote:
> /*I am trying to load an XML file from the following site, which btw is a working site you can put in the address bar.*/
> $url = "http://isbndb.com/api/books.xml?access_key=WC2BD24W&results=prices&index 1=isbn&value1=030681496x";
> //open the url
> if(!($handle = fopen($url, "r"))){
> echo "Error opening URL <br />".$url;
> exit();
> }
> else{
> echo "It Worked";
> //actually use simpleXML and parse it, but that's not the problem.
> }
>
> /*
> *For some reason that code returns:
> *Error opening URL
> *http://isbndb.com/api/books.xml?acce...ue1=030681496x
> *Is there something obvious that I am missing, or what?
> */


Check your configuration to see the value of: allow_url_fopen

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
Reply With Quote
  #6 (permalink)  
Old 07-06-2007
Kaleb Pomeroy
 
Posts: n/a
Default RE: [PHP] Loading a URL

That's it. Thanks a bunch Robert




-----Original Message-----
From: Robert Cummings [mailto:robert@interjinn.com]
Sent: Thu 05-Jul-07 8:53 PM
To: Kaleb Pomeroy
Cc: php-general@lists.php.net
Subject: Re: [php] Loading a URL

On Thu, 2007-07-05 at 20:39 -0500, Kaleb Pomeroy wrote:
> /*I am trying to load an XML file from the following site, which btw is a working site you can put in the address bar.*/
> $url = "http://isbndb.com/api/books.xml?access_key=WC2BD24W&results=prices&index 1=isbn&value1=030681496x";
> //open the url
> if(!($handle = fopen($url, "r"))){
> echo "Error opening URL <br />".$url;
> exit();
> }
> else{
> echo "It Worked";
> //actually use simpleXML and parse it, but that's not the problem.
> }
>
> /*
> *For some reason that code returns:
> *Error opening URL
> *http://isbndb.com/api/books.xml?access_key=WC2BD24W&results=prices&index 1=isbn&value1=030681496x
> *Is there something obvious that I am missing, or what?
> */


Check your configuration to see the value of: allow_url_fopen

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:20 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0