Passing Variables to a require_once() Page

This is a discussion on "Passing Variables to a require_once() Page" within the PHP Forum section. This forum, and the thread "Passing Variables to a require_once() Page are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 19th, 2006, 21:10
Up'n'Coming Member
Join Date: Mar 2006
Location: East Sussex, UK
Age: 20
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Passing Variables to a require_once() Page

Hi, I have a page that I want to add to all the pages on my site (the navigation), I am using require_once() to add the navigation html page to the pages, this is working beautifully. But how do I send a variable to the page in the require_once() function? For example:
PHP: Select all

  $nolinkindex "5"; @ require_once ("common/nav.html"); 

Reply With Quote

  #2 (permalink)  
Old Jun 19th, 2006, 22:29
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sypher
Re: Passing Variables to a require_once() Page

u mean $_POST['name'] ?
Reply With Quote
  #3 (permalink)  
Old Jun 20th, 2006, 00:32
Junior Member
Join Date: Jun 2006
Location: Wisconsin
Age: 30
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Passing Variables to a require_once() Page

you should be able to put $var = $_POST['name']; in the require_once file and then use it on the page that has the included file.
Reply With Quote
  #4 (permalink)  
Old Jun 20th, 2006, 18:36
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Passing Variables to a require_once() Page

The require_once() function is only needed when you are pulling in a file of functions and you code is such that this command could execute more than once.

If you just need to pull in a common html file, such as the navigation for a site, then you should be using the
Code: Select all
include('navigation.html');
instruction.

Any php code within this file can pick up any variables set by other snippets of php elsewhere in the host file.
Reply With Quote
Reply

Tags
passing, variables, require_once, page

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables from PHP to Flash tox0tes Flash & Multimedia Forum 4 Dec 29th, 2007 06:46
Passing Flash variables between frames lostnights Flash & Multimedia Forum 0 Jan 22nd, 2007 17:09
Passing variables from Flash to PHP LostProphet Flash & Multimedia Forum 6 Aug 31st, 2006 14:05
passing post variables benbacardi PHP Forum 5 Jul 5th, 2005 22:13
PLEASE HELP - Passing Variables in Querystring just_the_basix Classic ASP 40 Sep 3rd, 2004 10:46


All times are GMT. The time now is 20:42.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43