Jump to content

Help required related global variable


dearmoawiz

Recommended Posts

hi Guys

    i m new in php i want help regarding global variables or any other way to use variable globally ...

  here is the scenario!!!!

      i want to use a variable through out my application which have different folders and files as well ... if i change the value of a variable in one place then in whole application whenever i use that variable i must get the updated value of that variable ...

        waiting for your response ..

                          Enjoy!!!

Link to comment
https://forums.phpfreaks.com/topic/101188-help-required-related-global-variable/
Share on other sites

You want to look at using sessions

 

In all the scripts where you want to share a variable, start your scripts with:

<?php
session_start();
?>

 

Where you want to set a variable, do

<?php
$_SESSION['var'] = 'some value';
?>

 

When you want to use it, do:

<?php
$var = $_SESSION['var'];
//
// or
//
echo $_SESSION['var'];
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.