Re: [PHP] Heredoc inside eval?

2009-02-14 Thread Michael N. Madsen

Hehe ok..

First problem was that eval() was giving error because there was 
double-quotes in the template.


Second problem an attempt to fix problem 1 by wrapping the template in a 
heredoc syntax.


Problem 1 I solved as described with add/strip-slashes().

Out of curiosity I will test your suggestions to see if they would have 
worked and this I will post back on :)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Heredoc inside eval?

2009-02-14 Thread Nitsan Bin-Nun
I haven't figured from your sayings if my solutions worked? I haven't tested
them so I thought you would check them out ;)

Nitsan

On Sat, Feb 14, 2009 at 6:59 PM, Michael N. Madsen  wrote:

> Sorry for not including a a code example of the template.
>
> 
> ..
>{$content}
>
> This template I read into a variable using file_get_contents() so I don't
> think escaping php will work but I will have to test this.
>
> Your suggestion for the heredoc problem is simple, yet I didn't think of it
> :D
>
> Thanks for help, I'll post back when I have tested it.
>
> For others who come across this situation, the way I solved it was to
> simply use the addslashes()/stripslashes() functions as they only target
> double quotes by default. Should be (much?) less cpu intensive then using
> htmlspecialchars() as most of the html template would be altered.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Heredoc inside eval?

2009-02-14 Thread Michael N. Madsen

Sorry for not including a a code example of the template.


..
{$content}

This template I read into a variable using file_get_contents() so I 
don't think escaping php will work but I will have to test this.


Your suggestion for the heredoc problem is simple, yet I didn't think of 
it :D


Thanks for help, I'll post back when I have tested it.

For others who come across this situation, the way I solved it was to 
simply use the addslashes()/stripslashes() functions as they only target 
double quotes by default. Should be (much?) less cpu intensive then 
using htmlspecialchars() as most of the html template would be altered.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Heredoc inside eval?

2009-02-14 Thread Nitsan Bin-Nun
For instance you have:


The simplest way to eval() it is to use:
eval("?>" . $string_of_html_and_php . "
On Sat, Feb 14, 2009 at 3:58 PM, Michael  wrote:

> I have a html template with php variables. I then run it through eval().
> All that works fine. Problem is that when I add simple html attributes or
> javascript calls I need to use single or double quotes. And this is where
> eval throws an error. So I then used htmlspecialchars to mask all the
> non-php code and then decode after eval. Then I remembered the heredoc
> syntax which allows both single and double quotes. So I wrote this line:
>
>eval("\$html=<<
> But eval keeps giving me a parse error:
>
>Parse error: syntax error, unexpected $end in index.php(33) :
>eval()'d code on line 13
>
> I have tried using \r\n instead which returns error at line 11.
> If I wrap the variable in {} as it should results in line 11 also.
> If I insert a space after the 'hds' I get a T_SL error.
> I have tried to make a wrapper heredoc variable for $html but that didn't
> have any effect.
>
> I am running out of ideas...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] heredoc

2006-12-19 Thread Micky Hulse
I think I have come across situations where heredoc is the most 
useful/best solution... although, I can not remember any specific 
examples...


I would hate to see it deprecated... I find it very useful from time to 
time. :)




--
 Wishlist: 
   Switch: 
 BCC?: 
   My: 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc

2006-12-19 Thread Jochem Maas
clr wrote:
> Please can someone advise me on heredoc and its shortcommings,
> 
> I am designing a complex site and elected to use DIV's as opposed to
> frames.
> Heredoc seems to be ideal in that I can do all processing first and then
> layout with relative ease.

I would say go right ahead and use it...

> 
> I was wondering if it was acceptable to use and maintain going forward
> as i have read on a few mailing archives
> that this is a "cheat" and lazy and to be depreciated??

you have been misled - heredoc is not scheduled to be depreciated, it's
valid and useful tool (Paul N. offered you some of it's pro's) - my only gripe 
about
heredoc is that most of my editors can't handle it in terms of syntax highlight 
:-)

> 
> 
> Thanks
> Colin
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc

2006-12-18 Thread Casey Chu

I usually use an include rather than a heredoc.

On 12/18/06, Paul Novitski <[EMAIL PROTECTED]> wrote:

At 12/18/2006 10:14 PM, clr wrote:
>Please can someone advise me on heredoc and its shortcommings,
>
>I am designing a complex site and elected to use DIV's as opposed to frames.
>Heredoc seems to be ideal in that I can do all processing first and
>then layout with relative ease.
>
>I was wondering if it was acceptable to use and maintain going
>forward as i have read on a few mailing archives
>that this is a "cheat" and lazy and to be depreciated??


Yikes!  Then a scoundrel I must be indeed.  I love using heredoc,
primarily because it lets me compose blocks of pure output text
without interrupting it with control structures, nested quotes, and
concatenation syntax, even when it contains nested variables.  It
helps me to separate logic from markup, something that benefits my
code (if not my character!).

I imagine you'll hear from others whose sensibilities are offended by
heredoc -- in particular those whose careful indentation it spoils --
so I wanted to make sure you knew that it had an (admittedly cheating
and lazy yet) ardent supporter as well.

I don't know whom, in programming, you can cheat other than yourself;
I've been suffering under the misapprehension that laziness is a
virtue because it teaches efficiency; but I really hadn't heard that
heredoc was going to be deprecated.  If it is then it will be my loss
and the gain of those who earn royalties from the use of quotation
marks and periods and who make their living pulling the tangled and
bloody fragments of logic and markup from the wreckage of their collision.

Regards,
Paul

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc

2006-12-18 Thread Paul Novitski

At 12/18/2006 10:14 PM, clr wrote:

Please can someone advise me on heredoc and its shortcommings,

I am designing a complex site and elected to use DIV's as opposed to frames.
Heredoc seems to be ideal in that I can do all processing first and 
then layout with relative ease.


I was wondering if it was acceptable to use and maintain going 
forward as i have read on a few mailing archives

that this is a "cheat" and lazy and to be depreciated??



Yikes!  Then a scoundrel I must be indeed.  I love using heredoc, 
primarily because it lets me compose blocks of pure output text 
without interrupting it with control structures, nested quotes, and 
concatenation syntax, even when it contains nested variables.  It 
helps me to separate logic from markup, something that benefits my 
code (if not my character!).


I imagine you'll hear from others whose sensibilities are offended by 
heredoc -- in particular those whose careful indentation it spoils -- 
so I wanted to make sure you knew that it had an (admittedly cheating 
and lazy yet) ardent supporter as well.


I don't know whom, in programming, you can cheat other than yourself; 
I've been suffering under the misapprehension that laziness is a 
virtue because it teaches efficiency; but I really hadn't heard that 
heredoc was going to be deprecated.  If it is then it will be my loss 
and the gain of those who earn royalties from the use of quotation 
marks and periods and who make their living pulling the tangled and 
bloody fragments of logic and markup from the wreckage of their collision.


Regards,
Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc

2006-12-18 Thread Chris

clr wrote:

Please can someone advise me on heredoc and its shortcommings,

I am designing a complex site and elected to use DIV's as opposed to 
frames.
Heredoc seems to be ideal in that I can do all processing first and then 
layout with relative ease.


I was wondering if it was acceptable to use and maintain going forward 
as i have read on a few mailing archives

that this is a "cheat" and lazy and to be depreciated??


I think it comes down to personal preference. Some people use it and 
like, some don't. If you want to use it, do it. It's just "another 
option" to consider..


I don't think it's going to be removed any time soon (I'm sure there 
would be plenty of upset people & plenty of broken applications if it 
was removed).


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-29 Thread Larry Garfield
On Saturday 28 October 2006 18:15, Robert Cummings wrote:

> >As far as I can tell, single and double quotes
> > are interchangeable (but unmixable) in both HTML
> > and XHTML. When did single quotes go bad?
>
> Hmmm, I've been under the impression for quite some time that single
> quotes are somehow inferior to double quotes, but having just checked
> through both the XHTML and XML standard I couldn't find anything that
> supports that stance :/
>
> Cheers,
> Rob.

I've been using single quoted (X)HTML attributes for some time now without 
trouble.  The only catch is when you're dynamically building a DOM 1 
attribute like onclick, as the Javascript inside will almost invariably have 
a quotation mark in there somewhere, which by convention is single-quoted and 
the HTML double quoted.  Of course, you should be using DOM 2 event handlers 
anyway, but that's beside the point... :-)

It surprised me, too, when I realized single quotes were kosher (X)HTML, but 
it can be quite convenient.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   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



Re: [PHP] heredoc usage [WAS:

2006-10-28 Thread Robert Cummings
On Sat, 2006-10-28 at 13:27 +0200, Nisse Engström wrote:
> On Thu, 26 Oct 2006 13:10:17 -0400, Robert Cummings wrote:
> 
> > On Thu, 2006-10-26 at 11:43 +0200, clive wrote:
> >> or you could write it likes this '
> >> echo " $day ";
> >> 
> >> much easier to read, but slightly more taxing on the server.
> > 
> > Also slightly more taxing on standards since single quotes are bad :)
> 
>As far as I can tell, single and double quotes
> are interchangeable (but unmixable) in both HTML
> and XHTML. When did single quotes go bad?

Hmmm, I've been under the impression for quite some time that single
quotes are somehow inferior to double quotes, but having just checked
through both the XHTML and XML standard I couldn't find anything that
supports that stance :/

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.  |
`'

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-28 Thread Paul Novitski



On Thu, 26 Oct 2006 01:04:25 -0700, Paul Novitski wrote:

> It's so interesting that some details bug some people and others bug
> others.  In an expression such as this:
>
>  echo '' . $day
> . '';
>
> ...I count eight transitions (instances of switching between PHP
> syntax and output text) -- one each time you open or close a quote --
> compared to just two transitions (the opening & closing labels) for
> the comparable heredoc statement:
>
>  print <<< hdDay
>  $day
>
> hdDay;


At 10/28/2006 04:28 AM, Nisse Engström wrote:

   That's funny. I count eight transitions in both
examples. The difference in the second example is
that the transition switches have changed from
open/closing quote to '$'/not-a-variable-character.



Yes, from the point of view of the PHP parser, a 
transition is made each time you encounter an 
embedded variable requiring evaluation and each 
time you return to the quoted expression that 
doesn't require that same kind of evaluation.


What I was referring to were transitions of PHP 
syntactical punctuation that fragment the 
expression from the human point of view.  I 
personally find the heredoc expression much 
easier to read, proofread, and maintain because 
it appears to be all one simple, unbroken expression.


Regards,
Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-28 Thread Nisse Engström
On Thu, 26 Oct 2006 01:04:25 -0700, Paul Novitski wrote:

> It's so interesting that some details bug some people and others bug 
> others.  In an expression such as this:
> 
>  echo '' . $day 
> . '';
> 
> ...I count eight transitions (instances of switching between PHP 
> syntax and output text) -- one each time you open or close a quote -- 
> compared to just two transitions (the opening & closing labels) for 
> the comparable heredoc statement:
> 
>  print <<< hdDay
>  $day
> 
> hdDay;
> 

   That's funny. I count eight transitions in both
examples. The difference in the second example is
that the transition switches have changed from
open/closing quote to '$'/not-a-variable-character.


  --nfe

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-28 Thread Nisse Engström
On Thu, 26 Oct 2006 13:10:17 -0400, Robert Cummings wrote:

> On Thu, 2006-10-26 at 11:43 +0200, clive wrote:
>> or you could write it likes this '
>> echo " $day ";
>> 
>> much easier to read, but slightly more taxing on the server.
> 
> Also slightly more taxing on standards since single quotes are bad :)

   As far as I can tell, single and double quotes
are interchangeable (but unmixable) in both HTML
and XHTML. When did single quotes go bad?


  --nfe

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-27 Thread Paul Novitski



At 10:23 AM -0700 10/26/06, Paul Novitski wrote:
For a robust general CMS, though, I want a completely unambiguous 
demarcation of replacable content.


At 10/27/2006 09:01 AM, tedd wrote:
If you want "a completely unambiguous demarcation" then use xml with 
a defined schema. I don't think you can get any more defined than that, right?


Yes, I find XHTML markup sufficiently specific for my CMS.

Cheers,
Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-27 Thread tedd

At 1:09 PM -0400 10/26/06, Robert Cummings wrote:

On Thu, 2006-10-26 at 11:24 -0400, tedd wrote:

 At 1:04 AM -0700 10/26/06, Paul Novitski wrote:
 >At 10/25/2006 11:24 PM, Robert Cummings wrote:
 >>I use a tag based template system, there's no PHP in my content so my
 >>content files for the most part just look like more HTML.
 >
 >This is a different topic, but also one close to my heart.  Yes, I
 >too use my own selector-based templating system.  It does allow me
 >to embed PHP variables into the template if I want, but the primary
 >merge between plain HTML template and MySQL content happens through
 >CSS-style selectors.

 I also embed php variables inside css -- it gives it more functionality.


I embed them in the CSS template, which is compiled to a CSS stylesheet
file and so the variables become static after compilation. This is
useful if you're not determining values by any PHP logic, since then
your stylesheet can be served up as a static document while retaining
the flexibility of using variably defined values to generate the
stylesheet.

Cheers,
Rob.


Rob:

I think that's the only way it can be done except doing things with 
Ajax. If so, then styesheets can become "dynamic" -- but when served, 
they are static.


For me, I just provide a header at the beginning of the css file and 
a .htaccess rule to treat css suffix files as php documents.


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-27 Thread tedd

At 10:23 AM -0700 10/26/06, Paul Novitski wrote:

At 10/26/2006 08:24 AM, tedd wrote:
I think  a  would work just as well --  seems so 
old-world to me. :-)


By default, div is a block element and span is inline, so span 
seemed like the natural fit for a sentence fragment.  I don't think 
there's anything old-world (!) about spans, Tedd, they're just tags. 
I use both in my markup with a clear conscience.


My bad -- spans just remind me of the old "How do we slip things in" 
days instead of figuring out a way to work around it. I realize that 
they are both tags, but as Stut reminded me, one is block and the 
other is line element.


However, if you used preg_match_all, I think you could do away with 
the spans all together by matching FIRSTNAME to your first name 
variable. That way your document would simply read:


   Hello FIRSTNAME


That's true, and in tighly-defined micro-contexts that might work 
just fine.  For a robust general CMS, though, I want a completely 
unambiguous demarcation of replacable content.  All-caps tags will 
work in some circumstances but certainly won't in others.


If you want "a completely unambiguous demarcation" then use xml with 
a defined schema. I don't think you can get any more defined than 
that, right?


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Paul Novitski

At 10/26/2006 08:24 AM, tedd wrote:

At 1:04 AM -0700 10/26/06, Paul Novitski wrote:

My comparable example (but in an HTML context) would look like:

Hello FIRSTNAME,

where the engine replaces the content of the span with the value 
from the database based on a match of 'span.firstName' or perhaps 
just '.firstName'.  (In this example the 'FIRSTNAME' content in the 
template is merely a place-holder to make it easier to preview the 
markup and isn't necessary to the merge process.)


I think  a  would work just as well --  seems so 
old-world to me. :-)


By default, div is a block element and span is inline, so span seemed 
like the natural fit for a sentence fragment.  I don't think there's 
anything old-world (!) about spans, Tedd, they're just tags.  I use 
both in my markup with a clear conscience.



However, if you used preg_match_all, I think you could do away with 
the spans all together by matching FIRSTNAME to your first name 
variable. That way your document would simply read:


   Hello FIRSTNAME


That's true, and in tighly-defined micro-contexts that might work 
just fine.  For a robust general CMS, though, I want a completely 
unambiguous demarcation of replacable content.  All-caps tags will 
work in some circumstances but certainly won't in others.


Regards,
Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Robert Cummings
On Thu, 2006-10-26 at 11:43 +0200, clive wrote:
> Paul Novitski wrote:
> > It's so interesting that some details bug some people and others bug 
> > others.  In an expression such as this:
> >
> > echo '' . $day . 
> > '';
> or you could write it likes this '
> echo " $day ";
> 
> much easier to read, but slightly more taxing on the server.

Also slightly more taxing on standards since single quotes are bad :)

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.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Robert Cummings
On Thu, 2006-10-26 at 11:24 -0400, tedd wrote:
> At 1:04 AM -0700 10/26/06, Paul Novitski wrote:
> >At 10/25/2006 11:24 PM, Robert Cummings wrote:
> >>I use a tag based template system, there's no PHP in my content so my
> >>content files for the most part just look like more HTML.
> >
> >This is a different topic, but also one close to my heart.  Yes, I 
> >too use my own selector-based templating system.  It does allow me 
> >to embed PHP variables into the template if I want, but the primary 
> >merge between plain HTML template and MySQL content happens through 
> >CSS-style selectors.
> 
> I also embed php variables inside css -- it gives it more functionality.

I embed them in the CSS template, which is compiled to a CSS stylesheet
file and so the variables become static after compilation. This is
useful if you're not determining values by any PHP logic, since then
your stylesheet can be served up as a static document while retaining
the flexibility of using variably defined values to generate the
stylesheet.

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.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Robert Cummings
On Thu, 2006-10-26 at 10:50 +0100, Arpad Ray wrote:
> Incidentally, a nice side effect of heredoc is that some editors (like 
> vim) recognise << accordingly.

That's really cool. Never even thought to do that. I wonder if anyone
has done the footwork for joe to save me some time *hehe*.

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.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Robert Cummings
On Thu, 2006-10-26 at 01:04 -0700, Paul Novitski wrote:
> At 10/25/2006 11:24 PM, Robert Cummings wrote:
> >Now, the thing that I dislike about heredoc for such small strings is
> >the switching between heredoc mode and the switching back. It's ugly on
> >the scale of switching in and out of PHP tags.
> 
> It's so interesting that some details bug some people and others bug 
> others.  In an expression such as this:
> 
>  echo '' . $day 
> . '';

HEY! what's with all those spaces around the dots? ;)

> ...I count eight transitions (instances of switching between PHP 
> syntax and output text) -- one each time you open or close a quote -- 
> compared to just two transitions (the opening & closing labels) for 
> the comparable heredoc statement:
> 
>  print <<< hdDay
>  $day
> 
> hdDay;
> 
> 
> >it would be less ugly if
> >the closing delimiter didn't have to be at the beginning of it's own
> >line in which case code could still maintain indentation formatting.
> 
> I agree.  Too bad the PHP developers didn't come up with a special 
> symbol for heredoc closing labels to give us more control over script 
> formatting.  I do however find this a fairly minor irritation, a 
> small price to pay for heredoc's power.
> 
> 
> >To lighten the mess of heredoc I
> >personally use the following format:
> >
> > $foo = <<<_
>  ...
> >_;
> 
> Nice and concise!  Thanks, I'll use that.
> 
> 
> >However that's only useful if indenting the content is not an issue.
> 
> I don't see how you draw that conclusion.  Heredoc doesn't become 
> useless if we need to indent the content, it just means we lose 
> complete control over indenting every line of our PHP script.  The 
> functionality is still totally there.

Sorry, I should have re-iterated -- useful to my sense of aesthetics :D

> 
> This script indenting issue with heredoc is for me one of the few 
> irritations of PHP.  I love the language and the power that heredoc 
> gives me.  I'm also irritated by the class member syntax $this->that 
> but I still use it as well.

Oh yeah, in no way do i think that heredoc reduces PHP. I love PHP too,
one of it's great attractions is the flexibility it gives to the
developer while not being reduced to a pile of PERL resembling
gibberish :) Mind you, some developers are extremely adept at making
their code look like gibberish regardless.

> > > I ask because I use heredoc all the time, sometimes for inline code
> > > as above but most often for template assembly, maintaining HTML in
> > > external files that can be edited independently of the PHP logic.
> >
> >I use a tag based template system, there's no PHP in my content so my
> >content files for the most part just look like more HTML.
> 
> This is a different topic, but also one close to my heart.  Yes, I 
> too use my own selector-based templating system.  It does allow me to 
> embed PHP variables into the template if I want, but the primary 
> merge between plain HTML template and MySQL content happens through 
> CSS-style selectors.
> 
> 
> >Hello ,
> 
> Cool.
> 
> My comparable example (but in an HTML context) would look like:
> 
>  Hello FIRSTNAME,
> 
> where the engine replaces the content of the span with the value from 
> the database based on a match of 'span.firstName' or perhaps just 
> '.firstName'.  (In this example the 'FIRSTNAME' content in the 
> template is merely a place-holder to make it easier to preview the 
> markup and isn't necessary to the merge process.)

Out of curiosity is your template engine just a search and replace based
on the span tags? Mine involves parsing out the tags and recompilation
of tag generated content (so you can output template tags within a
template tag). Tags can also load modules and provide meta logic. The
following is an example of a form template:













Username:






Password:





























As you may be noticing, my template engine is a pull engine. Modules are
pulled into play by the template and accessed via the render tags (the
 tag shows another way to access module fields). The exception
is for the email example I formerly sent since the email module is
instantiated for the email template by virtue of being loaded by the
mail service -- but the email template can also load modules and can
access any other custom tags created for the project. For instance I
often have tags like the following:


Some content


Which means only a user with admin access will see the content. Also,
for simplicity I'll have:



Which will inject the firstName value of the currently logged in user.

So basically, my code never references my templates, my templates just
include modules themselves which makes the code far more re

Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Stut

tedd wrote:
I think  a  would work just as well --  seems so old-world 
to me. :-)


The span element is in no way old-world. Spans and divs are two 
different things with different goals. A div is a block-level element, 
whereas spans are inline. Spans are intended for stylistic changes that 
span a chunk of text within a block. Divs are intended to describe the 
block.


Not really relevant to the discussion, but worth pointing out.

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread tedd

At 1:04 AM -0700 10/26/06, Paul Novitski wrote:

At 10/25/2006 11:24 PM, Robert Cummings wrote:

I use a tag based template system, there's no PHP in my content so my
content files for the most part just look like more HTML.


This is a different topic, but also one close to my heart.  Yes, I 
too use my own selector-based templating system.  It does allow me 
to embed PHP variables into the template if I want, but the primary 
merge between plain HTML template and MySQL content happens through 
CSS-style selectors.


I also embed php variables inside css -- it gives it more functionality.




Hello ,


Cool.

My comparable example (but in an HTML context) would look like:

Hello FIRSTNAME,

where the engine replaces the content of the span with the value 
from the database based on a match of 'span.firstName' or perhaps 
just '.firstName'.  (In this example the 'FIRSTNAME' content in the 
template is merely a place-holder to make it easier to preview the 
markup and isn't necessary to the merge process.)


I think  a  would work just as well --  seems so old-world 
to me. :-)


However, if you used preg_match_all, I think you could do away with 
the spans all together by matching FIRSTNAME to your first name 
variable. That way your document would simply read:


   Hello FIRSTNAME

Just an idea.

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Arpad Ray
Incidentally, a nice side effect of heredoc is that some editors (like 
vim) recognise <

Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread clive

Paul Novitski wrote:
It's so interesting that some details bug some people and others bug 
others.  In an expression such as this:


echo '' . $day . 
'';

or you could write it likes this '
   echo " $day ";

much easier to read, but slightly more taxing on the server.

--
Regards,

Clive

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-26 Thread Paul Novitski

At 10/25/2006 11:24 PM, Robert Cummings wrote:

Now, the thing that I dislike about heredoc for such small strings is
the switching between heredoc mode and the switching back. It's ugly on
the scale of switching in and out of PHP tags.


It's so interesting that some details bug some people and others bug 
others.  In an expression such as this:


echo '' . $day 
. '';


...I count eight transitions (instances of switching between PHP 
syntax and output text) -- one each time you open or close a quote -- 
compared to just two transitions (the opening & closing labels) for 
the comparable heredoc statement:


print <<< hdDay
$day

hdDay;



it would be less ugly if
the closing delimiter didn't have to be at the beginning of it's own
line in which case code could still maintain indentation formatting.


I agree.  Too bad the PHP developers didn't come up with a special 
symbol for heredoc closing labels to give us more control over script 
formatting.  I do however find this a fairly minor irritation, a 
small price to pay for heredoc's power.




To lighten the mess of heredoc I
personally use the following format:

$foo = <<<_

...

_;


Nice and concise!  Thanks, I'll use that.



However that's only useful if indenting the content is not an issue.


I don't see how you draw that conclusion.  Heredoc doesn't become 
useless if we need to indent the content, it just means we lose 
complete control over indenting every line of our PHP script.  The 
functionality is still totally there.


This script indenting issue with heredoc is for me one of the few 
irritations of PHP.  I love the language and the power that heredoc 
gives me.  I'm also irritated by the class member syntax $this->that 
but I still use it as well.




> I ask because I use heredoc all the time, sometimes for inline code
> as above but most often for template assembly, maintaining HTML in
> external files that can be edited independently of the PHP logic.

I use a tag based template system, there's no PHP in my content so my
content files for the most part just look like more HTML.


This is a different topic, but also one close to my heart.  Yes, I 
too use my own selector-based templating system.  It does allow me to 
embed PHP variables into the template if I want, but the primary 
merge between plain HTML template and MySQL content happens through 
CSS-style selectors.




Hello ,


Cool.

My comparable example (but in an HTML context) would look like:

Hello FIRSTNAME,

where the engine replaces the content of the span with the value from 
the database based on a match of 'span.firstName' or perhaps just 
'.firstName'.  (In this example the 'FIRSTNAME' content in the 
template is merely a place-holder to make it easier to preview the 
markup and isn't necessary to the merge process.)




| InterJinn Application Framework - http://www.interjinn.com |


Interesting project!  Good work.

Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc usage [WAS:

2006-10-25 Thread Robert Cummings
On Wed, 2006-10-25 at 22:53 -0700, Paul Novitski wrote:
> > > At 10/25/2006 04:09 PM, Stut wrote:
> > > > print ' > > > if ($selected_day_of_month == $day)
> > > > print ' selected';
> > > > print '>'.$day.'';
> 
> On Wed, 2006-10-25 at 17:35 -0700, Paul Novitski wrote:
> > >  print <<< hdDay
> > >  $day
> > >
> > > hdDay;
> 
> At 10/25/2006 06:57 PM, Robert Cummings wrote:
> >Ewww, I'll take Stut's style anyday. Heredoc has its uses, but I
> >wouldn't consider your above usage one of them :/ Now to add my own
> >flavour...
> > echo ''
> > .$day
> > .'';
> 
> 
> Rob, I'd love to know what aspect of my heredoc usage you find 
> objectionable.

Now this is obviously just opinion since everyone is entitled to their
own style, and while I might find it objectionable, I hardly represent
the masses and their idiosyncrasies :)

Now, the thing that I dislike about heredoc for such small strings is
the switching between heredoc mode and the switching back. It's ugly on
the scale of switching in and out of PHP tags. it would be less ugly if
the closing delimiter didn't have to be at the beginning of it's own
line in which case code could still maintain indentation formatting.
Understandably it is not like this since it's flexibility lies in being
able to place very versatile content within while not accidentally
breaking out of heredoc context. To lighten the mess of heredoc I
personally use the following format:


blah blah blah blah blah blah blah blah blah blah
blah blah $foo blah blah blah blah blah blah blah
blah blah blah blah blah blah $fee blah blah blah
blah blah blah blah blah blah blah blah blah blah

_;

?>
However that's only useful if indenting the content is not an issue.

>   From my perspective it's a single integrated 
> expression, cleaner, easier to read and proofread, and easier to 
> maintain than a concatenation of expression fragments strung together 
> with syntactical punctuation and quotation marks.  I especially value 
> the fact that heredoc lets me separate program logic from text output 
> to the greatest extent possible.  Am I unwittingly committing a 
> stylistic or logical faux pas?
> 
> Conversely, what applications of heredoc do you find valid and valuable?

My example also illustrates the kind of content I would be willing to
contain within a heredoc... namely a large chunk of content, most likely
with a mix of double quotes and variables. That said, I'm still more
likely not to use heredoc... I think the one exception where I'm quite
likely to use heredoc is when I'm declaring a javascript function from
within a PHP function.

> I ask because I use heredoc all the time, sometimes for inline code 
> as above but most often for template assembly, maintaining HTML in 
> external files that can be edited independently of the PHP logic.

I use a tag based template system, there's no PHP in my content so my
content files for the most part just look like more HTML. The templates
are compiled to PHP (or raw content such as when creating stylesheets)
after which they are used over and over without recompiling. here's an
example of an email template:


Hello ,

You or somebody posing as you has requested that your password
be reset. If you did not request this email then you may disregard
it and no changes will be made to your account.

To continue please click on the link below and complete the form
that will be presented. If clicking on the link does not open
your browser then please copy and paste the address into a web
browser to continue.

http:///reset.php?rid=

Sincerely,
Admin


Here's the code that invokes the template:

getServiceRef( 'mail' );

$mail->addTo( $to );
$mail->setSubject( 'BlahBlah.com - Reset Password Request' );
$mail->setTemplate( '//emails/passwordResetDetails.php', $data );
$mail->send();

?>

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.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc question

2006-05-05 Thread Al

Robert Cummings wrote:

On Fri, 2006-05-05 at 10:40, Al wrote:
How can I include "place holders" for variables in a heredoc such that after the heredoc is declared, I can assign the 
variables?


I have a config file with a heredoc string declared.  I'd like to keep the 
include config.inc at the top of my page.

Down in the page, when I call the heredoc variable, I'd like to replace the "place holders" with a values assigned in 
the page, below the include statement.


I know I can break up the heredoc into several segments and put the variables 
between them; but, I rather not.

Seems like there should be an obvious way to do this.


str_replace() ??

Rob.


Yes, that is the simplest solution.  Now that you've refreshed my memory, I've 
done it that way in the past.

Thanks...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc question

2006-05-05 Thread Dave Goodchild

Or just use str_replace

On 05/05/06, John Nichel <[EMAIL PROTECTED]> wrote:


Al wrote:
> How can I include "place holders" for variables in a heredoc such that
> after the heredoc is declared, I can assign the variables?
>
> I have a config file with a heredoc string declared.  I'd like to keep
> the include config.inc at the top of my page.
>
> Down in the page, when I call the heredoc variable, I'd like to replace
> the "place holders" with a values assigned in the page, below the
> include statement.
>
> I know I can break up the heredoc into several segments and put the
> variables between them; but, I rather not.
>
> Seems like there should be an obvious way to do this.
>
> Thanks...
>

printf()?

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] heredoc question

2006-05-05 Thread Robert Cummings
On Fri, 2006-05-05 at 10:40, Al wrote:
> How can I include "place holders" for variables in a heredoc such that after 
> the heredoc is declared, I can assign the 
> variables?
> 
> I have a config file with a heredoc string declared.  I'd like to keep the 
> include config.inc at the top of my page.
> 
> Down in the page, when I call the heredoc variable, I'd like to replace the 
> "place holders" with a values assigned in 
> the page, below the include statement.
> 
> I know I can break up the heredoc into several segments and put the variables 
> between them; but, I rather not.
> 
> Seems like there should be an obvious way to do this.

str_replace() ??

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.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc question

2006-05-05 Thread Paul Novitski

At 07:40 AM 5/5/2006, Al wrote:
How can I include "place holders" for variables in a heredoc such 
that after the heredoc is declared, I can assign the variables?



Al,

Escape the $'s in your heredoc expression so that the variable names 
remain and aren't evaluated, then eval() the whole expression later:


$sString = <<< hdBodyClass

hdBodyClass;

This sets $sString equal to:



Then:
$sBodyClass = "contact";
eval("\$sHTML = '$sString';");

Evaluates as:

$sHTML = '';

As always, be careful not to include any external data in an eval() 
statement without careful sponging.  Its presence in your script 
should be regarded as an Achilles heel and treated with special respect.


Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc question

2006-05-05 Thread John Nichel

Al wrote:
How can I include "place holders" for variables in a heredoc such that 
after the heredoc is declared, I can assign the variables?


I have a config file with a heredoc string declared.  I'd like to keep 
the include config.inc at the top of my page.


Down in the page, when I call the heredoc variable, I'd like to replace 
the "place holders" with a values assigned in the page, below the 
include statement.


I know I can break up the heredoc into several segments and put the 
variables between them; but, I rather not.


Seems like there should be an obvious way to do this.

Thanks...



printf()?

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc syntax vs Double-Quotes

2006-03-15 Thread Paul Novitski

At 07:06 PM 3/15/2006, Chris Kennon wrote:

when is using heredoc advisable over Double-Quotes?



I love using heredoc primarily because it helps me separate logic 
from markup when generating HTML.  The text in a heredoc expression 
is vanilla, no escape sequences needed, so there's less worry about 
typos.  I find it one of the strongest features of PHP as compared to 
other scripting languages.


Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc syntax vs Double-Quotes

2006-03-15 Thread Chris

Chris Kennon wrote:

Hi,

Not looking to start some pugilistic fray, but when is using heredoc  
advisable over Double-Quotes?


Probably with really long strings or pages of data so you don't have to 
worry about quotes etc.


Pretty much comes down to personal preference I think.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc syntax

2004-10-20 Thread Matthew Weier O'Phinney
* Janet Valade <[EMAIL PROTECTED]>:
> Adil wrote:
>
>> anyone know why heredoc syntax might not work with php5/apache installed.  I
>> can't get even the simplest strings in heredoc syntax to work and I've tried
>> just cutting and pasting other peoples stuff in that syntax as well, and
>> still no luck
>
> Heredoc syntax is pretty rigid and it's easy to have it wrong invisibly.
^
That's the key -- whitespace is invisible to the naked eye typically.

> $varname = << Text of string
> END;
>
> The first END must be at the end of the line, nothing after it, not even 
> a blank space. The last END must be at the beginning of the line, not 
> before it, not even a blank space.

And don't forget that the last END must be followed by a semi-colon
ONLY, no other characters on that line... ;-)

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc syntax

2004-10-20 Thread Janet Valade
Adil wrote:
anyone know why heredoc syntax might not work with php5/apache installed.  I
can't get even the simplest strings in heredoc syntax to work and I've tried
just cutting and pasting other peoples stuff in that syntax as well, and
still no luck
thx.
Adil.
Heredoc syntax is pretty rigid and it's easy to have it wrong invisibly.
$varname = <<
The first END must be at the end of the line, nothing after it, not even 
a blank space. The last END must be at the beginning of the line, not 
before it, not even a blank space.

Janet

--
Janet Valade -- janet.valade.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Heredoc question

2003-06-06 Thread Mark
Or you can just escape out of PHP like so:


This is a test of the emergency broadcasting system. If this had been
an actual emergency, you would have been instructed to

read from the chapters of Matthew, Mark, Luke and DUCK!!


--- Sparky Kopetzky <[EMAIL PROTECTED]> wrote:
> I did figure a way around heredoc last night. Here's the solution
> if anyone
> can use it:
> 
>  $truth = true;
> $head = "brain bucket";
> $message = << This is a test of the emergency broadcasting system.
> If this had been an actual emergency, you would have
> been instructed to
> TEST;
> 
> if ($truth)
> {
> $message .= " place your {$head} between your legs and\n";
> }
> 
> $message .= << read from the chapters of Matthew, Mark, Luke
> and DUCK!!
> TEST;
> 
> print $message;
> ?>
> $message is actually works in heredoc just like any other string.
> Didn't
> expect that.
> Hope this helps someone else who is trying the same thing as I am.
> 
> Robin E. Kopetzky
> Black Mesa Computers/Internet Services
> www.blackmesa-isp.net
> 
> - Original Message -
> From: "Jennifer Goodie" <[EMAIL PROTECTED]>
> To: "Sparky Kopetzky" <[EMAIL PROTECTED]>; "PHP General"
> <[EMAIL PROTECTED]>
> Sent: Thursday, June 05, 2003 16:47
> Subject: RE: [PHP] Heredoc question
> 
> 
> > > Can one use  within the heredoc syntax or is there
> > > another way?? I'm trying to dynamically generate email from
> > > generic text but with obvious additions, like this:
> >
> > http://us4.php.net/types.string says that heredoc acts just like
> double
> > quoted, which would mean it expands variables, so I would try
> just
> throwing
> > them in there like this...
> >
> >
> >  $message = << >  Name: {$lot->get_name()}
> >
> >  Lot {$lot->get_id()} has been approved. Here is the
> >  link to the lot:
> >  my_message;
> >
> >
> > There's an example of almost exactly like this on that page.
> >
> >
> >
> >
> >
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


=
Mark Weinstock
[EMAIL PROTECTED]
***
You can't demand something as a "right" unless you are willing to fight to death to 
defend everyone else's right to the same thing.
***

__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Heredoc question

2003-06-06 Thread Jennifer Goodie
> That's fine for that but I have several places that use if's and else's...
>
> Sparky
> > http://us4.php.net/types.string says that heredoc acts just like double
> > quoted, which would mean it expands variables, so I would try just

Than I would suggest reading the manual page (the link I gave) to see if you
can do that.  Would you put an if or an else inside a double quoted string
and expect it to work?  I wouldn't.  Maybe I'm wrong though.  Read the
manual.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Heredoc question

2003-06-06 Thread Sparky Kopetzky
That's fine for that but I have several places that use if's and else's...

Sparky
- Original Message -
From: "Jennifer Goodie" <[EMAIL PROTECTED]>
To: "Sparky Kopetzky" <[EMAIL PROTECTED]>; "PHP General"
<[EMAIL PROTECTED]>
Sent: Thursday, June 05, 2003 16:47
Subject: RE: [PHP] Heredoc question


> > Can one use  within the heredoc syntax or is there
> > another way?? I'm trying to dynamically generate email from
> > generic text but with obvious additions, like this:
>
> http://us4.php.net/types.string says that heredoc acts just like double
> quoted, which would mean it expands variables, so I would try just
throwing
> them in there like this...
>
>
>  $message = <<  Name: {$lot->get_name()}
>
>  Lot {$lot->get_id()} has been approved. Here is the
>  link to the lot:
>  my_message;
>
>
> There's an example of almost exactly like this on that page.
>
>
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Heredoc question

2003-06-06 Thread Jennifer Goodie
> Can one use  within the heredoc syntax or is there
> another way?? I'm trying to dynamically generate email from
> generic text but with obvious additions, like this:

http://us4.php.net/types.string says that heredoc acts just like double
quoted, which would mean it expands variables, so I would try just throwing
them in there like this...


 $message = <get_id()} has been approved. Here is the
 link to the lot:
 my_message;


There's an example of almost exactly like this on that page.







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Heredoc question

2003-06-06 Thread Sparky Kopetzky
I did figure a way around heredoc last night. Here's the solution if anyone
can use it:


$message is actually works in heredoc just like any other string. Didn't
expect that.
Hope this helps someone else who is trying the same thing as I am.

Robin E. Kopetzky
Black Mesa Computers/Internet Services
www.blackmesa-isp.net

- Original Message -
From: "Jennifer Goodie" <[EMAIL PROTECTED]>
To: "Sparky Kopetzky" <[EMAIL PROTECTED]>; "PHP General"
<[EMAIL PROTECTED]>
Sent: Thursday, June 05, 2003 16:47
Subject: RE: [PHP] Heredoc question


> > Can one use  within the heredoc syntax or is there
> > another way?? I'm trying to dynamically generate email from
> > generic text but with obvious additions, like this:
>
> http://us4.php.net/types.string says that heredoc acts just like double
> quoted, which would mean it expands variables, so I would try just
throwing
> them in there like this...
>
>
>  $message = <<  Name: {$lot->get_name()}
>
>  Lot {$lot->get_id()} has been approved. Here is the
>  link to the lot:
>  my_message;
>
>
> There's an example of almost exactly like this on that page.
>
>
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Heredoc question

2003-06-05 Thread Joel Rees
> That's fine for that but I have several places that use if's and else's...

AFAIK, you can't do conditionals inside a here doc. But then you don't
have to build your entire output string in one here doc, either.

Hmm. Maybe you're trying to build templates?

-- 
Joel Rees <[EMAIL PROTECTED]>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc problem

2003-03-02 Thread Tom Rogers
Hi,

Monday, March 3, 2003, 8:02:14 AM, you wrote:
jvc> Can someone tell me what is wrong with the following code:

jvc> 
jvc> Testing
jvc> 
jvc>  $str = << Example of string 
jvc> spanning multiple lines 
jvc> using heredoc syntax.
jvc> EOD;
?>> 
jvc> 
jvc> 

jvc> This is code straight out of the PHP manual. I get the error:
jvc> Parse error: parse error, unexpected T_SL in testhere.php on line 5

jvc> I looked up T_SL and it is a token representing << so that means it just
jvc> doesn't get the <<<. Why not? I've tried all the combinations of spaces and
jvc> no space in that line that I can think of.

jvc> So, what's wrong. Undoubtedly something obvious to anyone except me.

jvc> Janet


You have a space at the end of >>>EOD
Get rid of it and it should work

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc problem

2003-03-02 Thread janet
In a message dated 3/2/2003 3:55:50 PM Pacific Standard Time,
[EMAIL PROTECTED] writes:

>when I copy/pasted directly from your email and tried to execute it, I can
>an error on line 5 too
>
>I noticed that there's a space at the end of line 5, I deleted it and it
>worked fine.
>

That's it. That is the problem. Good eye.

Thank you,

Janet


>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Monday, March 03, 2003 9:02 AM
>> To: [EMAIL PROTECTED]
>> Subject: [PHP] heredoc problem
>> 
>> 
>> Can someone tell me what is wrong with the following code:
>> 
>> 
>> Testing
>> 
>> > $str = <<> Example of string 
>> spanning multiple lines 
>> using heredoc syntax.
>> EOD;
>> ?> 
>> 
>> 
>> 
>> This is code straight out of the PHP manual. I get the error:
>> Parse error: parse error, unexpected T_SL in testhere.php on line 5
>> 
>> I looked up T_SL and it is a token representing << so that 
>> means it just
>> doesn't get the <<<. Why not? I've tried all the combinations 
>> of spaces and
>> no space in that line that I can think of.
>> 
>> So, what's wrong. Undoubtedly something obvious to anyone except me.
>> 
>> Janet
>> 
>> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] heredoc problem

2003-03-02 Thread Martin Towell
when I copy/pasted directly from your email and tried to execute it, I can
an error on line 5 too

I noticed that there's a space at the end of line 5, I deleted it and it
worked fine.

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 03, 2003 9:02 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] heredoc problem
> 
> 
> Can someone tell me what is wrong with the following code:
> 
> 
> Testing
> 
>  $str = << Example of string 
> spanning multiple lines 
> using heredoc syntax.
> EOD;
> ?> 
> 
> 
> 
> This is code straight out of the PHP manual. I get the error:
> Parse error: parse error, unexpected T_SL in testhere.php on line 5
> 
> I looked up T_SL and it is a token representing << so that 
> means it just
> doesn't get the <<<. Why not? I've tried all the combinations 
> of spaces and
> no space in that line that I can think of.
> 
> So, what's wrong. Undoubtedly something obvious to anyone except me.
> 
> Janet
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] heredoc problem

2003-03-02 Thread Ernest E Vogelsinger
At 23:02 02.03.2003, [EMAIL PROTECTED] said:
[snip] 
>Can someone tell me what is wrong with the following code:
>
>This is code straight out of the PHP manual. I get the error:
>Parse error: parse error, unexpected T_SL in testhere.php on line 5
>
>I looked up T_SL and it is a token representing << so that means it just
>doesn't get the <<<. Why not? I've tried all the combinations of spaces and
>no space in that line that I can think of.
[snip] 

The correct heredoc syntax:

$text = <