User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,753 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,481 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1740 | Replies: 7
Reply
Join Date: Jun 2005
Location: USA
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

PHP Includes +

  #1  
Jul 25th, 2005
I am new at php so this might me a dumb question.

Is it possible to use part of an include file another words i make an 1 big include file and only use parts of it as needed and not make many include files.

Also is it possible to delete an whole variable so that it dont messes thing up when we get back to same page with diffrent info in th variable.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Posts: 12
Reputation: bgharper is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
bgharper bgharper is offline Offline
Newbie Poster

Re: PHP Includes +

  #2  
Jul 25th, 2005
Originally Posted by ashneet
I am new at php so this might me a dumb question.

Is it possible to use part of an include file another words i make an 1 big include file and only use parts of it as needed and not make many include files.

Also is it possible to delete an whole variable so that it dont messes thing up when we get back to same page with diffrent info in th variable.

In the include file, if you do if statements, you can then include parts of it. This is how I typically call parts of an include file. Example of an include.php...

[PHP]<?php if ( $page == "1" ) { ?>
Page 1
<?php elseif ($page == "2" ) { ?>
Page 2[/PHP]

And so forth. Call it like this...

[PHP]<?php include "include.php?page=1"; ?>[/PHP]

Second, to "delete" a variable, you can use the unset function. This essentially destroys the variable.

[PHP]<?php unset($var1, $var2, $var3); ?>[/PHP]

Hope this helps.
Reply With Quote  
Join Date: Jun 2005
Location: USA
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: PHP Includes +

  #3  
Jul 25th, 2005
ok thanks is there a command to unset any thing in a POST as i think when you use POST the variable stay there until the person exit browser or something. also does GET also stay in the computer like POST
Reply With Quote  
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: PHP Includes +

  #4  
Jul 25th, 2005
You do not set or unset the built in $_POST, $_GET. They only exist for the life of the script. They do not persist between server hits.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Join Date: Jun 2005
Location: USA
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: PHP Includes +

  #5  
Jul 25th, 2005
you mean that when i go to next page and that page redirect me back to the page where the variable mean something then the variable wont work if so that would work better as i am making a program that goes back and forth in 2 or 3 pages alot
Reply With Quote  
Join Date: Jul 2005
Posts: 21
Reputation: Class is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Class's Avatar
Class Class is offline Offline
Newbie Poster

Solution Re: PHP Includes +

  #6  
Jul 30th, 2005
Hi!

I also have a couple of questions to the include function of php! :!:
I don't know if it's possible to make:
Lest say i have index.php file, where i have included = photos.html with thumbnails, and if a click on one of the tn-s that this include changes to tn01.html where the bigpicture is, and if i click here on 'return'-link include will change back to photos.html????
Reply With Quote  
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: PHP Includes +

  #7  
Jul 31st, 2005
Originally Posted by Class
Lest say i have index.php file, where i have included = photos.html with thumbnails, and if a click on one of the tn-s that this include changes to tn01.html where the bigpicture is, and if i click here on 'return'-link include will change back to photos.html????

Class, first of all, just want you to know that at Daniweb, we prefer you to create your own thread rather than post a new question to somebody else's thread. It helps keep the discussion in a particular thread focused. Also, it will help you get a response as people tend to look for threads with zero replies to see if they can help.

bgharper shows one example of what you can do in this very thread--scroll up to his post to see it. In his example, you could create a single page that either displays the thumbnails or displays a single photo. This one page could then be included. But to answer your question, yes. With PHP, you can conditionally include files. This is NOT an option with ASP/VBScript--one of the many powerful advantages of PHP. You just use standard if/else/end or select/case logic to conditionally include files. Check out include(), require(), and my favorite, require_once().
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Join Date: Jul 2005
Posts: 21
Reputation: Class is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Class's Avatar
Class Class is offline Offline
Newbie Poster

Re: PHP Includes +

  #8  
Jul 31st, 2005
Sorry....will never happen again! :o

Well, yeah a saw in the beginning the upper example, but i don't really understand it. But I will see, maybe after i saw those php manuals!

Thanks!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 8:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC