Re: [PHP] Assign variable to a block of html code

2007-12-22 Thread php mail
Hi Everyone,

Thanks for pointing me to heredoc syntax. I've got it working out nicely now
;)

Regards,

Feris

On 12/20/07, Daniel Brown [EMAIL PROTECTED] wrote:

 On Dec 19, 2007 10:38 PM, php mail [EMAIL PROTECTED] wrote:
  Hi All,
 
  Is it possible to assign variable to a block of html code ?
 
  Something like this :
 
  $myblokvar = 
  table width=487 border=0 cellspacing=0 cellpadding=0
tr
  tdtable width=487 border=0 cellspacing=0 cellpadding=0
 [snp]
  /table/td
/tr
  /table
  ;
 
  Although example above is not working, what I want to achieve is
 something
  like that. Is it possible how can I do that ?

 If you absolutely want to do it that way, then escape your quotes
 in the HTML.  When you're using quotes to encapsulate a variable, any
 quotes contained within the value will cause a parse error.  One
 alternative is to use single-quotes for variable containment, and
 double-quotes throughout, or vice-versa.  These two methods will work:

 $variable = This is how you \escape\ quotes.;
 $variable = 'Using single quotes gives you the literal value,
 which means you can't do newlines and such.\n';

 However, your best bet is going to be using HEREDOC:

 $html =EOL

 Always be sure to use the three left carats as shown in the line
 above.  You can call EOL anything you want in the world, as long as it
 doesn't interfere with an existing part of your code within the same
 scope.  You can also use $variables within a HEREDOC, but things like
 newlines WILL NOT work.\n

 Also note that, when using HEREDOC syntax, you don't end the
 EOL with a semicolon.  And when you're done with your HEREDOC
 block, be sure to end it as the first thing on the line.  You can't
 have any spaces, tabs, or other characters before it.  And be sure to
 place your semicolon after it, as well, like so:
 EOL;

 --
 Daniel P. Brown
 [Phone Numbers Go Here!]
 [They're Hidden From View!]

 If at first you don't succeed, stick to what you know best so that you
 can make enough money to pay someone else to do it for you.



Re: [PHP] Assign variable to a block of html code

2007-12-20 Thread Darren Whitlen

Xavier de Lapeyre wrote:
You should try the HEREDOC structure. 
See link: http://php.net/heredoc


It should look to something like:

$myblokvar = EOF
table blabla
tr
td
			Welcome $name to this website! 
		/td

/tr
/table
EOF;


Xavier,

You should test this before you send it.. it doesn't even parse!
The closing EOF should not start with the . It should only be the 
identifier (EOF) followed by ; and a new line.


-
$myblokvar = EOF
table blabla
.

EOF;
-

Darren



No need of quotes or php start/end tags when placing a variable.

To use it afterwards simply call the $mylokvar variable.

Hope it helped!

Xavier
Web Developer
Site: www.eds.mu




-Original Message-
From: Stephen Johnson [mailto:[EMAIL PROTECTED] 
Sent: jeudi 20 décembre 2007 07:43

To: php mail; PHP General List
Subject: Re: [PHP] Assign variable to a block of html code

What you have will work, you just need to escape out the double quotes in
the html.  





On 12/19/07 7:38 PM, php mail [EMAIL PROTECTED] wrote:


Hi All,

Is it possible to assign variable to a block of html code ?

Something like this :

$myblokvar = 
table width=487 border=0 cellspacing=0 cellpadding=0
  tr
tdtable width=487 border=0 cellspacing=0 cellpadding=0
  tr
tdimg src=images/bartitle_login.gif alt=Login width=475
height=30 //td
tdnbsp;/td
  /tr
  tr
td class=produktable width=100% border=0 cellpadding=3
cellspacing=2
  tr
td class=katalog
?=$log_info?
/td
  /tr
  /table/td
tdnbsp;/td
  /tr
  tr
td class=produknbsp;/td
tdnbsp;/td
  /tr
/table/td
  /tr
/table
;

Although example above is not working, what I want to achieve is something
like that. Is it possible how can I do that ?

Regards,

Feris




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



Re: [PHP] Assign variable to a block of html code

2007-12-20 Thread Peter Ford
You could just swap all the double quotes in the HTML tags for single quotes -
that would work in this instance...

$myblokvar = 
table width='487' border='0' cellspacing='0' cellpadding='0'
...
/table
;


Or perhaps a HereDoc syntax:

$myblokvar = EndOfMyHTMLBlock
table width=487 border=0 cellspacing=0 cellpadding=0
...
/table
EndOfMyHTMLBlock;

Then you don't need to worry about what quotes you use, and if you start putting
stuff like onclick events in you can mix quotes up happily ...


I go to great lengths to avoid escaping quotes - it just looks ugly.
That is, however, a personal foible.

Cheers
Pete


Stephen Johnson wrote:
 What you have will work, you just need to escape out the double quotes in
 the html.  
 
 
 
 
 On 12/19/07 7:38 PM, php mail [EMAIL PROTECTED] wrote:
 
 Hi All,

 Is it possible to assign variable to a block of html code ?

 Something like this :

 $myblokvar = 
 table width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdtable width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdimg src=images/bartitle_login.gif alt=Login width=475
 height=30 //td
 tdnbsp;/td
   /tr
   tr
 td class=produktable width=100% border=0 cellpadding=3
 cellspacing=2
   tr
 td class=katalog
 ?=$log_info?
 /td
   /tr
   /table/td
 tdnbsp;/td
   /tr
   tr
 td class=produknbsp;/td
 tdnbsp;/td
   /tr
 /table/td
   /tr
 /table
 ;

 Although example above is not working, what I want to achieve is something
 like that. Is it possible how can I do that ?

 Regards,

 Feris
 

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



Re: [PHP] Assign variable to a block of html code

2007-12-20 Thread Daniel Brown
On Dec 19, 2007 10:38 PM, php mail [EMAIL PROTECTED] wrote:
 Hi All,

 Is it possible to assign variable to a block of html code ?

 Something like this :

 $myblokvar = 
 table width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdtable width=487 border=0 cellspacing=0 cellpadding=0
[snp]
 /table/td
   /tr
 /table
 ;

 Although example above is not working, what I want to achieve is something
 like that. Is it possible how can I do that ?

If you absolutely want to do it that way, then escape your quotes
in the HTML.  When you're using quotes to encapsulate a variable, any
quotes contained within the value will cause a parse error.  One
alternative is to use single-quotes for variable containment, and
double-quotes throughout, or vice-versa.  These two methods will work:

$variable = This is how you \escape\ quotes.;
$variable = 'Using single quotes gives you the literal value,
which means you can't do newlines and such.\n';

However, your best bet is going to be using HEREDOC:

$html =EOL

Always be sure to use the three left carats as shown in the line
above.  You can call EOL anything you want in the world, as long as it
doesn't interfere with an existing part of your code within the same
scope.  You can also use $variables within a HEREDOC, but things like
newlines WILL NOT work.\n

Also note that, when using HEREDOC syntax, you don't end the
EOL with a semicolon.  And when you're done with your HEREDOC
block, be sure to end it as the first thing on the line.  You can't
have any spaces, tabs, or other characters before it.  And be sure to
place your semicolon after it, as well, like so:
EOL;

-- 
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

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



RE: [PHP] Assign variable to a block of html code

2007-12-20 Thread Xavier de Lapeyre
Yeps,
Sorry bout that.

Thnks for pointing it out.
Xavier



-Original Message-
From: Darren Whitlen [mailto:[EMAIL PROTECTED] 
Sent: jeudi 20 décembre 2007 13:13
To: php-general@lists.php.net
Subject: Re: [PHP] Assign variable to a block of html code

Xavier de Lapeyre wrote:
 You should try the HEREDOC structure. 
 See link: http://php.net/heredoc
 
 It should look to something like:
 
 $myblokvar = EOF
 table blabla
   tr
   td
   Welcome $name to this website! 
   /td
   /tr
 /table
 EOF;

Xavier,

You should test this before you send it.. it doesn't even parse!
The closing EOF should not start with the . It should only be the 
identifier (EOF) followed by ; and a new line.

-
$myblokvar = EOF
table blabla
.

EOF;
-

Darren

 
 No need of quotes or php start/end tags when placing a variable.
 
 To use it afterwards simply call the $mylokvar variable.
 
 Hope it helped!
 
 Xavier
 Web Developer
 Site: www.eds.mu
 
 
 
 
 -Original Message-
 From: Stephen Johnson [mailto:[EMAIL PROTECTED] 
 Sent: jeudi 20 décembre 2007 07:43
 To: php mail; PHP General List
 Subject: Re: [PHP] Assign variable to a block of html code
 
 What you have will work, you just need to escape out the double quotes in
 the html.  
 
 
 
 
 On 12/19/07 7:38 PM, php mail [EMAIL PROTECTED] wrote:
 
 Hi All,

 Is it possible to assign variable to a block of html code ?

 Something like this :

 $myblokvar = 
 table width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdtable width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdimg src=images/bartitle_login.gif alt=Login width=475
 height=30 //td
 tdnbsp;/td
   /tr
   tr
 td class=produktable width=100% border=0 cellpadding=3
 cellspacing=2
   tr
 td class=katalog
 ?=$log_info?
 /td
   /tr
   /table/td
 tdnbsp;/td
   /tr
   tr
 td class=produknbsp;/td
 tdnbsp;/td
   /tr
 /table/td
   /tr
 /table
 ;

 Although example above is not working, what I want to achieve is something
 like that. Is it possible how can I do that ?

 Regards,

 Feris
 

-- 
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] Assign variable to a block of html code

2007-12-20 Thread Xavier de Lapeyre
Quote:

You could just swap all the double quotes in the HTML tags for single quotes -
that would work in this instance...

$myblokvar = 
table width='487' border='0' cellspacing='0' cellpadding='0'
...
/table
;


That's a way too, but it does not preserve the indentation.
The HEREDOC syntax behave much like the pre HTML tag for PHP, and it also 
removed the hassle of placing escape tags!

Xavier de Lapeyre
Web Developer
Enterprise Data Services
24, Dr Roux Street, 
Rose Hill
Office: (230) 465 17 00
Fax: (230) 465 29 00
Site: www.eds.mu





-Original Message-
From: Peter Ford [mailto:[EMAIL PROTECTED] 
Sent: jeudi 20 décembre 2007 13:17
To: php-general@lists.php.net
Subject: Re: [PHP] Assign variable to a block of html code

You could just swap all the double quotes in the HTML tags for single quotes -
that would work in this instance...

$myblokvar = 
table width='487' border='0' cellspacing='0' cellpadding='0'
...
/table
;


Or perhaps a HereDoc syntax:

$myblokvar = EndOfMyHTMLBlock
table width=487 border=0 cellspacing=0 cellpadding=0
...
/table
EndOfMyHTMLBlock;

Then you don't need to worry about what quotes you use, and if you start putting
stuff like onclick events in you can mix quotes up happily ...


I go to great lengths to avoid escaping quotes - it just looks ugly.
That is, however, a personal foible.

Cheers
Pete


Stephen Johnson wrote:
 What you have will work, you just need to escape out the double quotes in
 the html.  
 
 
 
 
 On 12/19/07 7:38 PM, php mail [EMAIL PROTECTED] wrote:
 
 Hi All,

 Is it possible to assign variable to a block of html code ?

 Something like this :

 $myblokvar = 
 table width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdtable width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdimg src=images/bartitle_login.gif alt=Login width=475
 height=30 //td
 tdnbsp;/td
   /tr
   tr
 td class=produktable width=100% border=0 cellpadding=3
 cellspacing=2
   tr
 td class=katalog
 ?=$log_info?
 /td
   /tr
   /table/td
 tdnbsp;/td
   /tr
   tr
 td class=produknbsp;/td
 tdnbsp;/td
   /tr
 /table/td
   /tr
 /table
 ;

 Although example above is not working, what I want to achieve is something
 like that. Is it possible how can I do that ?

 Regards,

 Feris
 

-- 
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] Assign variable to a block of html code

2007-12-19 Thread Stephen Johnson
What you have will work, you just need to escape out the double quotes in
the html.  




On 12/19/07 7:38 PM, php mail [EMAIL PROTECTED] wrote:

 Hi All,
 
 Is it possible to assign variable to a block of html code ?
 
 Something like this :
 
 $myblokvar = 
 table width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdtable width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdimg src=images/bartitle_login.gif alt=Login width=475
 height=30 //td
 tdnbsp;/td
   /tr
   tr
 td class=produktable width=100% border=0 cellpadding=3
 cellspacing=2
   tr
 td class=katalog
 ?=$log_info?
 /td
   /tr
   /table/td
 tdnbsp;/td
   /tr
   tr
 td class=produknbsp;/td
 tdnbsp;/td
   /tr
 /table/td
   /tr
 /table
 ;
 
 Although example above is not working, what I want to achieve is something
 like that. Is it possible how can I do that ?
 
 Regards,
 
 Feris

-- 
Stephen Johnson
The Lone Coder

http://www.ouradoptionblog.com
*Join us on our adoption journey*

[EMAIL PROTECTED]
http://www.thelonecoder.com

*Continuing the struggle against bad code*
--

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



RE: [PHP] Assign variable to a block of html code

2007-12-19 Thread Xavier de Lapeyre
You should try the HEREDOC structure. 
See link: http://php.net/heredoc

It should look to something like:

$myblokvar = EOF
table blabla
tr
td
Welcome $name to this website! 
/td
/tr
/table
EOF;

No need of quotes or php start/end tags when placing a variable.

To use it afterwards simply call the $mylokvar variable.

Hope it helped!

Xavier
Web Developer
Site: www.eds.mu




-Original Message-
From: Stephen Johnson [mailto:[EMAIL PROTECTED] 
Sent: jeudi 20 décembre 2007 07:43
To: php mail; PHP General List
Subject: Re: [PHP] Assign variable to a block of html code

What you have will work, you just need to escape out the double quotes in
the html.  




On 12/19/07 7:38 PM, php mail [EMAIL PROTECTED] wrote:

 Hi All,
 
 Is it possible to assign variable to a block of html code ?
 
 Something like this :
 
 $myblokvar = 
 table width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdtable width=487 border=0 cellspacing=0 cellpadding=0
   tr
 tdimg src=images/bartitle_login.gif alt=Login width=475
 height=30 //td
 tdnbsp;/td
   /tr
   tr
 td class=produktable width=100% border=0 cellpadding=3
 cellspacing=2
   tr
 td class=katalog
 ?=$log_info?
 /td
   /tr
   /table/td
 tdnbsp;/td
   /tr
   tr
 td class=produknbsp;/td
 tdnbsp;/td
   /tr
 /table/td
   /tr
 /table
 ;
 
 Although example above is not working, what I want to achieve is something
 like that. Is it possible how can I do that ?
 
 Regards,
 
 Feris

-- 
Stephen Johnson
The Lone Coder

http://www.ouradoptionblog.com
*Join us on our adoption journey*

[EMAIL PROTECTED]
http://www.thelonecoder.com

*Continuing the struggle against bad code*
--

-- 
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