function test($matches)
{
$fx = '';
if(strpos($matches[0],"http://")===false)
{
$fx = "http://";
}
elseif(strpos($matches[0],"http:/")===false)
{
$fx = "http:/";
}
elseif(strpos($matches[0],"http:")===false)
{
$fx = "http:";
}
elseif(strpos($matches[0],"http")===false)
{
$fx = "http";
}
return $fx.$matches[0];
}
またはこれらのPHPスクリプトはサーバーのメモリを少なくしますか?
function test($matches)
{
if(strpos($matches[0],"http://")===false)
{
return "http://".$matches[0];
}
elseif(strpos($matches[0],"http:/")===false)
{
return "http:/".$matches[0];
}
elseif(strpos($matches[0],"http:")===false)
{
return "http:".$matches[0];
}
elseif(strpos($matches[0],"http")===false)
{
return "http".$matches[0];
}
}
私はできるだけ少ないメモリを使用し、それらに私のスクリプトを記述しようとしているが、時にはコードをIDKのだが、醜い見て、私のopnionに最初のスクリプトは、よりきれいに見えると組織化が、私はそれがサーバーのより多くのメモリを使用すると思います。
ありがとうございました。
['memory_get_usage()'](http://us3.php.net/manual/en/function.memory-get-usage.php)と['memory_get_peak_usage()'](http: /us3.php.net/manual/en/function.memory-get-peak-usage.php)。 –
しかし、サーバーのパフォーマンスが低下しているか、サーバーの要求を満たすことができない場合を除いて、実際には心配する必要はありません。これらの2つの違い(もしあれば)はそれほど無視することはできません。 –
これらの関数は、2つの異なるものを返します。最初のものは結果を返し、2番目のものは返さない。あなたはスイッチケースの機能もテストしています。 – iambriansreed