@The_Little_GuyMay 30.2006 — #to include a file within another file.
Say you want to make a navigation menu, you can put it in one file, maybe called nav.php
Then on the page where you put your navigation, you just use [B]include('nav.php');[/B] and bam all of your navigation is on that page. It save alot of coding time.
Another scenario...
You could make a file containing all your functions fuctions.php, and at the very beginning of your webpage files such as index.php you could use [B]include('fuctions.php');[/B] now instead of adding the fuctions to every page you just link to fuctions.php
This can be done with preset variables, page layouts, connecting to databases, hold a login layout, headers, footers, I think you get my drift.
The [B][url=http://www.php.net/manual/en/function.include.php]include()[/url][/B] statement includes and evaluates the specified file.
The documentation below also applies to [B][url=http://www.php.net/manual/en/function.require.php]require()[/url][/B]. The two constructs are identical in every way except how they handle failure. [B][url=http://www.php.net/manual/en/function.include.php]include()[/url][/B] produces a [url=http://www.php.net/manual/en/phpdevel-errors.php#internal.e-warning]Warning[/url] while [B][url=http://www.php.net/manual/en/function.require.php]require()[/url][/B] results in a [url=http://www.php.net/manual/en/phpdevel-errors.php#internal.e-error]Fatal Error[/url]. In other words, use [B][url=http://www.php.net/manual/en/function.require.php]require()[/url][/B] if you want a missing file to halt processing of the page. [B][url=http://www.php.net/manual/en/function.include.php]include()[/url][/B] does not behave this way, the script will continue regardless. Be sure to have an appropriate [url=http://www.php.net/manual/en/ini.core.php#ini.include-path]include_path[/url] setting as well. Be warned that parse error in included file doesn't cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does.
Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in include_path relative to the current working directory.
When a file is included, the code it contains inherits the [url=http://www.php.net/manual/en/language.variables.scope.php]variable scope[/url] of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward. However, all functions and classes defined in the included file have the global scope.
can any body please tell me what is the use of include() with the script...
thanks in advance..... ?[/QUOTE] In case you are not aware of it, all of the PHP functions and commands are easily looked up via the following link in your web browser:
www.php.net/<function_name>
...where <function_name> is the name of the function/command you want to know about, e.g. "www.php.net/include".
This is quite useful - e.g. example.com/index.php?page=blog would include blog.php. However example.com/index.php?page=http://nastyserver.com/evilscript would include someone else's script and effectively give them full control of your site.