+ 1

How do I access return both $conn and $status from a function?

<?php class EstablishConnection { var $conn; var $status= 'nothing so far'; function EstablishConnection(){ $servername = "dd"; $username = "dd"; $password = "dd"; $dbname = "dd"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { $status = "Connection was failed"; } else{ //$status value not being assigned outside function? $status = "Connection was established"; } return $conn; } }

25th Jun 2017, 12:28 PM
ISHTIAQUE BIN IDREES
ISHTIAQUE BIN IDREES - avatar
1 ответ
+ 1
I have currently achieved it using a array return. Any other optimum solution?
25th Jun 2017, 12:48 PM
ISHTIAQUE BIN IDREES
ISHTIAQUE BIN IDREES - avatar