簡単な質問です。そのようにメソッドを呼び出すと言います
mysql_pconnect("server","tator_w","password")
or die("Unable to connect to SQL server");
テキストメッセージを表示するのではなく、メソッドを呼び出させることはできますか? もしそうなら、どのように?
より複雑なことをしたい場合は、短絡評価に頼るのではなく、if ステートメントを使用する方がよいでしょう。
if (!mysql_pconnect("server","tator_w","password")) {
call_a_function();
//some other stuff
die(); //if you still want to die
}
It lets you register a function that will be called when the system exits. Then you can simply die()
or exit()
without a parameter, which will call your method.
(you may also find set_error_handler() interesting, if slightly unrelated)
まあ、正確ではありませんが、あなたはそうします
if(!mysql_pconnect("server","tator_w","password")) {
$some_obj->some_method();
exit(1);
}
文字列を返す関数呼び出しを入れてみませんか?
function myDieFunction()
{
// do some stuff
return("I died!");
}
die(myDieFunction());
または、レジスタシャットダウン機能を試すことができます
別の(しかしあまり良くない)方法:
mysql_pconnect("server","tator_w","password")
or foo() & bar() & die("Unable to connect to SQL server");
&
すべての関数を呼び出すには、ブール演算子ではなく二項演算子を使用することに注意してください。