私はいくつかの PHP プログラミングを行っていますが、質問があります: PHP スクリプトが最初に実行されたときに、最初に実行されたときにのみ PHP 関数をロードするにはどうすればよいですか?
ありがとう
私はいくつかの PHP プログラミングを行っていますが、質問があります: PHP スクリプトが最初に実行されたときに、最初に実行されたときにのみ PHP 関数をロードするにはどうすればよいですか?
ありがとう
またはプレーンブール値を使用してください...
$bFirstRun = true;
if( $bFirstRun ) {
run_me();
$bFirstRun = false;
}
というPHP関数があります。function_exists
この関数内に独自の関数を定義すると、これが存在するかどうかを確認できます。
if (!function_exists('myfunction')) {
function myfunction() {
// do something in the function
}
// call my function or do anything else that you like, from here on the function exists and thus this code will only run once.
}
function_exists の詳細については、http ://www.php.net/function_exists をご覧ください。