Current location: Hot Scripts Forums » Programming Languages » PHP » PHP variable


PHP variable

Reply
  #1 (permalink)  
Old 09-10-04, 10:44 AM
sharad sharad is offline
Newbie Coder
 
Join Date: Jun 2004
Location: noida
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation PHP variable

Hi,
How can I access a variable in multiple scripts. I want to declare a variable for once in a script and want to print the value this variable in each script kept in a same directory. Is it possible without using cookie?

Just tell me how to do this?
Reply With Quote
  #2 (permalink)  
Old 09-10-04, 11:07 AM
PromptLogic PromptLogic is offline
Newbie Coder
 
Join Date: Sep 2004
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
The only way to do this without cookies or sessions, that I know of, is to just include a file that delcares the variable. Create a file and put:

$your_variable_name = "your value";

Save it and name it whatever and than in each script, at the top put:

include("yourfile.php");

Of course you will need to global the file in if you will be using in functions and classes.


If that is not what you mean, let me now and I'll see whatelse I can come up with.
Reply With Quote
  #3 (permalink)  
Old 09-10-04, 02:06 PM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
another option to cookies is sesisons
PHP Code:

#page 1

session_start();
$_SESSION['var_name'] = "value";

#page 2
session_start();
echo 
$_SESSION['var_name']; 
note that session_start() must be called before anything is outputted to browser
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
php with Apache in windows eDevil PHP 3 08-08-04 12:03 AM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
[Tutorial] Hello World Antitrust PHP 10 10-14-03 01:27 PM
PHP MySQL Variable Help tgarske PHP 8 08-25-03 09:01 PM


All times are GMT -5. The time now is 04:28 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.