do inside a variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cwin
Forum Newbie
Posts: 2
Joined: Sat Nov 15, 2003 5:08 am

do inside a variable

Post by Cwin »

Is there any way to put a do{} inside a variable?
Like:

Code: Select all

$x = do {echo "something";} while ($y==1);
i know that doesn't work, but is there any way to make it work?

Code: Select all

[i]Why?.... read on[/i]

<?php
   function cwinsfunc($arg) {
   //This is where there is some code
   $x = 1;
   return <<<EOF
      This is a load of HTML<br>
      PHP will only replace variables, nothing else<br>
      echo ("hi") will return echo ("hi")<br>
      $x will return 1<br>
      <b>Bold Text</b><br>
      <br>
      So obviously i cant put a do in here
   EOF;
}
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

split your variable in half?

$x1 = all the HTML before the do loop
$x2 = everything afterwards

echo $x1;
do {} while loop;
echo $x2;

im not really sure what you're looking to do (or display).. hope i helped tho
Post Reply