Concatenation makes a slightly larger file, but it is: 1) Easier to read 2) More efficient when used with ' instead of "
If you use: echo "row = $row!"; then you're forcing PHP to do the concatenation internally. It's basically the same as: echo 'row ='.$row.'!'; Only it takes more parsing when using ". On Mon, 19 Jul 2004 17:45:01 -0700, XeRnOuS ThE <[EMAIL PROTECTED]> wrote: > > Well i already know about concatenation like that, but as you said, > resource hog, though this way isnt really much better for the most part i > just want to know. On the bright side of using this, while it takes a bit > more resources, if i dont have to exit the parent string ( echo "<tr $row()" > rather than echo "<tr".row().">";) > it is technicly saving me roughly 5 bits of filesize per usage, lol > > But thanks for the CSS script, ill try using that instead. But still, is it > even posisble to call functions like that in php? > > >From: Justin Patrin <[EMAIL PROTECTED]> > >Reply-To: [EMAIL PROTECTED] > >To: XeRnOuS ThE <[EMAIL PROTECTED]> > >CC: [EMAIL PROTECTED] > >Subject: Re: [PHP] Dynamic function calls within the echo function, > >possible? > >Date: Mon, 19 Jul 2004 17:27:03 -0700 > >MIME-Version: 1.0 > >Received: from mproxy.gmail.com ([64.233.170.203]) by mc2-f23.hotmail.com > >with Microsoft SMTPSVC(5.0.2195.6824); Mon, 19 Jul 2004 17:33:51 -0700 > >Received: by mproxy.gmail.com with SMTP id c11so298040rnb for > ><[EMAIL PROTECTED]>; Mon, 19 Jul 2004 17:33:47 -0700 (PDT) > >Received: by 10.38.73.11 with SMTP id v11mr12862rna; Mon, 19 Jul > >2004 17:27:03 -0700 (PDT) > >X-Message-Info: JGTYoYF78jESzP8alusJADEfHmc1ZYJK > >Message-ID: <[EMAIL PROTECTED]> > >In-Reply-To: <[EMAIL PROTECTED]> > >References: <[EMAIL PROTECTED]> > >Return-Path: [EMAIL PROTECTED] > >X-OriginalArrivalTime: 20 Jul 2004 00:33:51.0672 (UTC) > >FILETIME=[3AF24B80:01C46DF1] > > > >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> > >'; > >} > > > > _________________________________________________________________ > Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 > > !DSPAM:40fc68fc75091120856454! > > -- 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