Jump to content

session register VS $_SESSION[]


voip03
 Share

Recommended Posts

This code works. I can echo it.

<?

$username='HelloJay';

$_SESSION['USER_NAME']=$username;

 

echo $_SESSION['USER_NAME'];

?>

BUT this code dose not ?

<?
$username='HelloJay';
$_SESSION['USER_NAME']=$username;

echo $_SESSION['USER_NAME'];
?>

Link to comment
Share on other sites

session register

  • session register returns Boolean type output
  • session_register() is a php function used to register variables with the current session
  • it will work only when register global is turned on in php.ini configuration file

 

$_SESSION[]

  • $_session returns string
  • $_SESSION[] is a super global array
  • SESSION works in both case whether register_global is disabled or enabled

 

 

Link to comment
Share on other sites

Actually. <?= is making something of a comeback ( not <? though) as a shortcut for <?php echo

 

In 5.4:

 

<?= is now always available regardless of the short_tags setting (Rasmus)

 

This is good news IMO as it helps tidy the code used in allot of frameworks default view scripts.

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.