[wp-hackers] Using eval within Wordpress for a function
mixed with html
chris.hearn01 at ntlworld.com
chris.hearn01 at ntlworld.com
Tue Dec 2 13:17:59 GMT 2008
I am away from pc today but will try this as soon as I can, sounds like it might work
Otherwise, as you suggest, I wil have to split up the strings to treat them separately, and then better to add a new table than use a text file.
Thanks
Chris
>
> From: DD32 <wordpress at dd32.id.au>
> Date: 2008/12/02 Tue AM 12:31:36 GMT
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Using eval within Wordpress for a function mixed
> with html
>
> Not having tested it, But going off what you originally posted:
>
> function getStringFromFile($file) {
> $s = file_get_contents($file);
> eval('return ' . $s);
> }
> You need to combine the strings, not to insert one string inside the other
> i believe.
>
>
> On Tue, 02 Dec 2008 11:25:10 +1100, Chris <chris.hearn01 at ntlworld.com>
> wrote:
>
> > good point on sprintf() - but assumes that I know the link will always
> > have the bloginfo() as the variable.
> > I was trying to generalise it so that, for several records in a text
> > file, it would do the whole thing!
> > Thanks for suggestion
> > Does anyone know hwo to combine php functions and html using eval?? I
> > would still like to know.
> > Chris
> >
> >
> >
> >
> > Jason Webster wrote:
> >> Why don't you just use sprintf?
> >>
> >> $string = '<a rel="external nofollow" href="%s/juniors/mirror"><img
> >> src="/oldsite/images/junior/.thumbs/.mirror.jpg" alt="mirror.jpg"
> >> title="mirror.jpg" width="95%" /></a> <hr />';
> >>
> >> $string = sprintf($string, get_bloginfo('wpurl'));
> >>
> >> Done!
> >>
> >>
> >>
> >> Chris wrote:
> >>> Yes, quite right Otto,
> >>> I simplified it for the post and inadvertantly altered it in
> >>> theprocess - I am indeed returning $theresult in the actual code I am
> >>> trying out.
> >>>
> >>> The key thing is how to eval() a mixture of php and html to get same
> >>> result as if it was put straight into a php page.
> >>> I saw on php lots of discussion of eval(), and different ideas, but
> >>> also comments that none of them worked properly, so thought would ask
> >>> on the hackers list.
> >>>
> >>> just to re-iterate: this following type of code works straight in a
> >>> page,
> >>> <a rel="external nofollow"
> >>> href="'.get_bloginfo('wpurl').'/juniors/mirror"><img
> >>> src="/oldsite/images/junior/.thumbs/.mirror.jpg" alt="mirror.jpg"
> >>> title="mirror.jpg" width="95%" /></a> <hr />
> >>>
> >>> so what should it be so that I can pull it in from a text file, or a
> >>> database, and then eval() it will give same result?
> >>> Thanks
> >>> Chris
> >>>
> >>> Otto wrote:
> >>>> On Mon, Dec 1, 2008 at 3:58 PM, Chris <chris.hearn01 at ntlworld.com>
> >>>> wrote:
> >>>>
> >>>>> How to use eval() to get the proper result from this type of thing:
> >>>>> Assuming I read the above fragment from a text file into variable $s
> >>>>>
> >>>>> function myfunc($s)
> >>>>> eval('\$theresult= \$s;')
> >>>>> return $s;
> >>>>>
> >>>>
> >>>> Shouldn't you be returning $theresult?
> >>>>
> >>>> -Otto
> >>>> _______________________________________________
> >>>> wp-hackers mailing list
> >>>> wp-hackers at lists.automattic.com
> >>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>>>
> >>>>
> >>> _______________________________________________
> >>> wp-hackers mailing list
> >>> wp-hackers at lists.automattic.com
> >>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> >> _______________________________________________
> >> wp-hackers mailing list
> >> wp-hackers at lists.automattic.com
> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
-----------------------------------------
Email sent from www.virginmedia.com/email
Virus-checked using McAfee(R) Software and scanned for spam
More information about the wp-hackers
mailing list