Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Die question

Tags:

php

die

Just a quick question. Say a call a method like so

mysql_pconnect("server","tator_w","password")
               or die("Unable to connect to SQL server");

Can I have the 'die' call a method rather then display a text message? If so, how?

like image 664
Señor Reginold Francis Avatar asked Jan 24 '23 11:01

Señor Reginold Francis


1 Answers

You would be better off using an if statement rather than relying on short-circuit evaluation if you want to do anything more complicated, e.g.:

if (!mysql_pconnect("server","tator_w","password")) {
    call_a_function();
    //some other stuff
    die(); //if you still want to die
}
like image 139
Tom Haigh Avatar answered Jan 26 '23 01:01

Tom Haigh