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.

Recommended Answers

All 7 Replies

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 if ( $page == "1" ) { ?>
Page 1
<?php elseif ($page == "2" ) { ?>
Page 2

And so forth. Call it like this...

<?php include "include.php?page=1"; ?>

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

<?php unset($var1, $var2, $var3); ?>

Hope this helps.

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

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.

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

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????

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().

Sorry....will never happen again! :o :cool:

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.