I don't think that's my issue. The values are passed through a constructor. The code in the constructor is to call a function based on the number of arguments. You can remove the "global $table;" line as it has no bearing on the issue. The script uses the constructor to, in this case, call "user1()" and set the table name. So, locally, in the function user1(), it sets it, but then it doesn't outside of the function. What puzzles me is that I can call setTable() after creating the instance of the class, and it works just as it should, updating the class variable $table. So, the issue may very well be scope, but my problem is why user1() doesn't work but setTable() does when it's the exact same code.
So the following doesn't do anything:
<?php
require "../include/include_all.inc.php";
$user = new user("test1");
print "Table: ".$user->getTable()."<br><br>";
?>
It just prints out:
Table:
But then, on top of that, after creating the instance of the class, I can call user1 again, even though I know it was called by the constructor, and it works just as setTable() does:
<?php
require "../include/include_all.inc.php";
$user = new user("test1");
$user->user1("test2");
print "Table: ".$user->getTable()."<br><br>";
?>
Which outputs:
Table: test2
So, I guess the question in the end is why can't it set the class variable $table when the constructor calls user1() even though it can do it outside of the constructor?