print variable inside function - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: print variable inside function

Quoted text here. Click to load it

Ignoring the "jerks" means ignoring accurate and helpful advice.

Quoted text here. Click to load it

Wrong.  The `print()' language construct *always* returns `1'.  
Also, the return value can make `print()' useful in certain


Curtis Dyer
<? $x='<? $x=%c%s%c;printf($x,39,$x,39);?>';printf($x,39,$x,39);?>

Re: print variable inside function

ignore the jerks. My advice....

1) function goes first before while loop.
2) use echo instead of print because print returns true or false which
is unnecessary.
3) use double quotes in your html attributes. leaving them out or
using single quotes is ugly
4) send $i as an argument into function thereby avoiding global use
5) use cache control and echo the entire content rather then echo each
function run. This would lower echo/print use by almost 50%

function makeTable($i=0) {
    echo "<div class=\"big\"><div class=\"qa\">$i</div></div>\n";

while($i<=5)  {  makeTable($i);  $i++; }
$html = ob_get_contents(); ob_end_clean();
echo $html;


Site Timeline