[thelist] PHP show first 10 words of MySQL field
Paul Bennett
paul at teltest.com
Wed Aug 27 22:58:17 CDT 2003
Austin Harris wrote:
>I have now got it working, and very simple it is to;
>
>$rest = substr("$myrow[text]", 0, 180);
> echo("$rest");
>
may I make a PHP programming suggestion?
Using variables insided double quotes is making the PHP engine do more
work than it needs to, as it needs to scan the string before processing
it to see if there are any variables inside to parse.
Also, it makes it more difficult to see where your variables are when
inside the string, as visually they look like a part of the
double-quoted string.
It is good practice to get into the habit of doing something like:
echo 'here is some text with a '.$variable.' in the middle';
less processor work, and easier to debug IMHO
just my 2cents worth
--
------------------------------
Paul Bennett
Internet Developer
Teltest Electronic Design
------------------------------
Email: paul at teltest.com
Phone: 64 4 237 4557
Web: http://www.teltest.com
Wap: http://wap.teltest.com
More information about the thelist
mailing list