PHP Global variable in class is reset
- by Robert
I have a web form that manipulates records in a MySQL database. I have a method for displaying an edit interface for both creating new records and editing them
if ($_POST['new_page']) {
print "<h2>Create new page</h2>\n";
$isNew=1;
$this->EditForm();
} else if($_POST['edit']){
print "<h2>Edit page</h2>\n";
$isNew=0;
$this->EditForm();
}
I am trying to use the global variable $isNew to determine where a record is to be added or updated. However, whenever my SaveChanges() function is run, $isNew is always 0. $isNew is declared immediately after the class declaration, outside all of the functions.
class Editor{
public $isNew;