@mysql_connect and mysql_connect

后端 未结 5 1532
野趣味
野趣味 2021-02-06 01:22

I have no problem connecting to a database using PHP however in some scripts I have tested, I have seen a small difference in the connect command.

What is the differenc

5条回答
  •  悲&欢浪女
    2021-02-06 02:12

    If don't use any option something like this;

    if ("I'm just making test on my srv") {
       error_reporting(E_ALL);
    } else {
       error_reporting(0);
    }
    

    Then, it could be recommended for this situation;

    $conn = @mysql_connect(...);
    if ($conn === false) {
       // handle error
    }
    
    Or;
    
    @mysql_connect(...) or die("Could not connect to ...");
    

    So, @ suppresses the error if it exist at the line "where the suppressible function is used".

    // Suppressible? Yes, cos you can not apply @ to die, exit, eval ... functions if these are structural functions.

提交回复
热议问题