[Typo3-dev] char <-> string -> overhead -> speed

Peter Russ peter.russ at 4dfx.de
Fri Sep 24 21:36:11 CEST 2004


<?php
$stringChar='Test\nnewLine'; // 1
$stringString="Text\nnewLine"; // 2

//How does the printout look like?
echo nl2br($stringChar)."<br>".nl2br($stringString);
?>

What is the benefit of $stringChar compared to stringString?
I'm just wondering because to get similar results, either $stringChar 
has to be defined as
$stringChar='Test'.char(10).'newLine'; // 3
or some high performing function as explode or strreplace or ereg has to 
be involved.UuuOps.
This might be an overhead.

So
<?php
$imax=5000000;
$tStart=time();
for($i=0;$i<$imax;$i++) $stringString="Text\nnewLine";
$endTime=time()-$tStart;
echo "string=$endTime.<br>";
$tStart=time();
for($i=0;$i<$imax;$i++) $stringChar='Test'.chr(10).'newLine';
$endTime=time()-$tStart;
echo "chr=$endTime.<br>";
?>

string is about 50% more efficient.

Any idea why to stay with $stringChar?

Regs. Peter.





More information about the TYPO3-dev mailing list