PHP: preg_replace Fonksiyon fonksiyonu zaten ilan edildi söylüyor

0 Cevap php

The Function:

function doSomething($url){
    $url = "<a href=\"{$url}\" target=\"blank\" title=\"{$url}\">{$url}</a>";
    return $url;
}

The replacement

$content = preg_replace("#(http:\/\/+[^\s]+)#ie","doSomething('$1')", $content);

The Problem:

Fatal error: Cannot redeclare doSomething() (previously declared in http://example.com/test.php:69) in http://example.com/test.php on line 69

Note: güncel fonksiyon benim gerçek fonksiyonunu temsil etmez, ben bu durum için herhangi bir fonksiyonları gerekmez biliyorum ama benim gerçek kod ihtiyacım. Fakat bu aynı zamanda daha iyi bir örnektir.

0 Cevap