Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Use variable of one php file in another

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Use variable of one php file in another

Postby BandanaChaudhury » Fri Dec 14, 2012 5:12 am

I want to use some of the variable of a .php file (let a.php) in another php file (let b.php) for some calculation purposes.
How can i achieve it.
BandanaChaudhury
New php-forum User
New php-forum User
 
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

Re: Use variable of one php file in another

Postby BandanaChaudhury » Sat Dec 15, 2012 11:05 pm

Please can somebody reply.
BandanaChaudhury
New php-forum User
New php-forum User
 
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

Re: Use variable of one php file in another

Postby simplypixie » Sun Dec 16, 2012 1:52 am

The only ways to use variables from one php file in another are:

1. Use sessions to store the variables and make them available throughout the website

2. Post the data, using a form, from one page to the new page

3. Include the php file that holds the variables (and only this sort of data) into the next page

Sorry this is so basic but your question is very vague and I am not entirely sure exactly where the original data / variables are coming from and how you need to use them on the 2nd page.
User avatar
simplypixie
php-forum Active User
php-forum Active User
 
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire

Re: Use variable of one php file in another

Postby BandanaChaudhury » Sun Dec 16, 2012 8:25 am

Thank you, it solved my problem.
BandanaChaudhury
New php-forum User
New php-forum User
 
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.