Avatar of flowerbloom
flowerbloom

asked on 

How to use PHP $GLOBALS for database connection resource link?

Before calling the function the db connection shows "resource id #...", in the function it shows zero.
I am trying to avoid using "global ...".

$conn = db connection;
print_r($conn); // prints "resource id # ..."
function get_sql () {
  $conn = $GLOBALS['conn'];
  print_r($conn); // prints "0"
...
}

Open in new window

PHP

Avatar of undefined
Last Comment
flowerbloom

8/22/2022 - Mon