PHP Includes +

Reply

Join Date: Jun 2005
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

PHP Includes +

 
0
  #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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 12
Reputation: bgharper is an unknown quantity at this point 
Solved Threads: 0
bgharper bgharper is offline Offline
Newbie Poster

Re: PHP Includes +

 
0
  #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 Quick reply to this message  
Join Date: Jun 2005
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: PHP Includes +

 
0
  #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 Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: PHP Includes +

 
0
  #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 Quick reply to this message  
Join Date: Jun 2005
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: PHP Includes +

 
0
  #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 Quick reply to this message  
Join Date: Jul 2005
Posts: 21
Reputation: Class is an unknown quantity at this point 
Solved Threads: 0
Class's Avatar
Class Class is offline Offline
Newbie Poster

Re: PHP Includes +

 
0
  #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 Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: PHP Includes +

 
0
  #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 Quick reply to this message  
Join Date: Jul 2005
Posts: 21
Reputation: Class is an unknown quantity at this point 
Solved Threads: 0
Class's Avatar
Class Class is offline Offline
Newbie Poster

Re: PHP Includes +

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC