unlink() is used to delete physical files...So lets say you have foo.txt somewhere on your server... unlink(foo.txt) would delete it. unset() is used to null out the value of a given variable. So for instance: x = 200; echo(x); // 200 unset(x); echo(x); // null The difference between the functions unlink and unset unlink() is a function for file system handling. It will simply delete the file in context. Example for unlink() : <?php $fh = fopen('test.html', 'a'); fwrite($fh, '<h1>Hello world!</h1>'); fclose($fh); unlink('test.html'); ?> unset() is a function for variable management. It will make a variable undefined. (or) Unset () is used to destroy a variable in PHP. In can be used to remove a single variable, multiple variables, or an element from an array. It is phrased as Unset ($remove). Also Known As: Unset Variable, Destroy Variable Example for unset() : <?php // remove a single variable unset($a); // remove a singl...
We can use either session_register or $_SESSION for registering session variable in php. Find below the difference between both of them. session_register () is a function and $_SESSION is a superglobal array . session_register() is used to register a session variable and it works only when register_globals is turned on . ( Turning ON register_globals will create mesh-ups, but some applications (e.g OScommerce) requires turning ON of register_globals) But $_SESSION works even when register_globals is turned off. If session_start() was not called before session_register() is called, an implicit call to session_start() with no parameters will be made. But $_SESSION requires session_start() before use. session_register function returns boolean value and $_SESSION returns string value session_register() function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. We know that Webpages ar...
Comments
Post a Comment