Yo....:-/

Hmmm, this must be PHP5 as in PHP4 parameters can't be by ref and have
a default value.

You can just use concatenation (as you really should be for all vars
and function call in echo statements).

echo '<tr style="background-color: '.row_color().';"><td>data</td></tr>';

But then again, this is a waste of resources. Here's the CSS friendly way:

echo '<style>
.row1 {
  background-color: #c0c0c0;
}
.row2 {
  backgorund-color: #808080;
}
</style>
<table>
';

for($i = 0; $i < 5; ++$i) {
  echo '<tr class="row'.($i % 2 ? '1' : '2').'"><td>Row '.$i.'</td></tr>
';
}

On Mon, 19 Jul 2004 16:55:13 -0700, XeRnOuS ThE <[EMAIL PROTECTED]> wrote:
> Yo, i run some fairly simplistic sites, and still don't know to much PHP.
> 
> Anyways i have this function called row color, it works fairly simply.
> 
> $row1 = "bgcolor='#c0c0c0'";
> $row2 = "bgcolor='#808080'";
> function row_color(&$row_color=null)
> {
>           static $row_count=0;
>           $row_color = ($row_count % 2) ? $GLOBALS['row1'] :
> $GLOBALS['row2'];
>           $row_count++
>           return $row_color;
> }
> 
> what i want to do, is somehow dynamicly call that funciton within an echo or
> print function though.
> something like
> $row = "row_color";
> 
> echo "$row()<br>$row()<br>$row()";
> but i cant seem to find a way to properly do this. That just returns null
> values, i have been screwing around with it for about a week now, and
> another two weeks trying to get it working on classes, but i cant figure out
> if it is even possible to do.
> 
> The idea bewteen the &$row_color is so that i can optionally use referencing
> on other places in the scripts i have.
> -XeRnOuS
> 
> _________________________________________________________________
> Don't just search. Find. Check out the new MSN Search!
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> !DSPAM:40fc5db348948405712292!
> 
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

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

Reply via email to