Re: How do I include specific files?

From: Date: Mon, 02 Dec 2002 16:31:50 +0000
Subject: Re: How do I include specific files?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-126725@lists.php.net to get a copy of this message
Hi Roddie, The require or include functions will do this for you, see http://www.php.net/manual/en/function.include.php Paths are absolute to the file system, not where the web server path starts, eg suppose your file is at /usr/home/www/riddie/phpscripts/somedir/script.php you would include a file (into script.php) from the phpscripts directory using either require('/usr/home/www/riddie/phpscripts/myincfile.php') or require('../myincfile.php') but require('/phpscripts/myincfile.php') would not work as php does not work from paths set by the webserver. HTH, Kevin Roddie Grant <php_list@myword.co.uk> wrote in message news:BA11332F.5AE3%php_list@myword.co.uk... > I'm new to PHP, but from Lasso I'm used to the following sort of arrangement > (in pseudo-code) > > Search for matching records > If number found=1 > include "/folder/subfolder/file1" > If number found>1 > include "/folder/subfolder/file2" > If number found=0 > include "/anotherfolder/subfolder/file99" > > where the included file contains the appropriate code for displaying a list, > a detailed record etc. In fact the whole page is made up almost entirely > from a succession of included files. > > The paths all "hang" from the root as with HTML (for example <img > src="/images-folder-at-root-level/image.gif">). > > In PHP the include_path stops this process in its tracks. I'm with an ISP so > I don't suppose I can control include_path (.:/usr/local/lib/php). Are there > any other options? > > TIA > > Roddie Grant > roddie@myword.co.uk >

« previous php.general (#126725) next »