I have an id
of a project and an id
of a client that are sessions in php that are passed in JSON format. These are stored in global variables id_p
and id_c
so I can do multiple inserts and updates selects etc. with those ids.
When the user selects another project or changes the page, I need to unset these variables.
null
value from php
to the global vars to reset them? php
values on php
only if the file is required? The files where the queries take place are on separate files.If unset() is called inside a user-defined function, it unsets the local variables. If a user wants to unset the global variable inside the function, then he/she has to use $GLOBALS array to do so. The unset() function has no return value.
Deleting Global Variables. You can delete global variable definitions from Integration Server using Integration Server Administrator. If you delete a global variable that is used by a flow service, while executing the flow service, Integration Server will throw an exception and stop the service execution.
To delete a global variable from inside a function:Use the global keyword to mark the variable as global inside of the function. Use the del statement to delete the variable.
you can put those variables in aclass , then create pointer to object of that class in the 1st place will use those variables then pass this pointer to every methode need those variables , don`t forget to delete the object when you will not use .
To really unset them, use
unset ( $GLOBALS['id_p'] );
This also works in functions.
Source: http://toscho.de/2012/php-unset-unterschied-global-globals/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With