+ 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; } }
1 Answer
+ 1
I have currently achieved it using a array return. Any other optimum solution?