Re: [PHP] include file in a class with global/parent scope?
Martin Scotta wrote: Where is $vars? there is no $vars in your code... You can extract all the global space in the CScope method, it's quite simple, but less performant. class CScope { public $vars = 'class scope\n'; function cinclude($filename) { extract( $GLOBALS ); include('vars.php'); echo In class $vars\n; } } On Sun, Jun 14, 2009 at 1:41 PM, Daniel Kolbo kolb0...@umn.edu mailto:kolb0...@umn.edu wrote: Hello, I understand the why $vars is not in the global scope, but i was wondering if there was a way from within the class file to include a file in the parent's scope? i tried ::include('vars.php'), parent::include('vars.php'), but this breaks syntax... Please consider the following three files: 'scope.class.inc' ?php class CScope { public $vars = 'class scope\n'; function cinclude($filename) { include('vars.php'); echo In class $vars\n; } } ? 'vars.php' ?php //global $vars;//if this line is uncommented then the desired result is achieved however, i don't want to change all the variables to global scope (this file is includeded in other files where global scoped variables is not desireable). $vars = 'vars.php scope\n'; ? 'scope.php' ?php include('scope.class.inc'); $object = new CScope; $object-cinclude('vars.php'); echo In original $vars\n;//$vars is not defined*** ? Thanks, dK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Martin Scotta replace all $var with $vars. The extract method proposed is the opposite of what i'm looking to do. I want to bring the class's include scope into the calling object's scope. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file in a class with global/parent scope?
Hello, I've cleaned up my question a bit. I want the included file which is called within a method of a class to have the same scope as the instantiation of the class's object. That is, i want a class to include a file in the calling object's scope. How would one do this? 'test.php' ?php class CSomeClass { public function cinclude() { include('vars.php'); } } $object = new CSomeClass; $object-cinclude(); echo $vars;//i want this to print 'hi' include('vars.php'); echo obvious $vars; ? 'vars.php' ?php $vars = hi; ? OUTPUT: Notice: Undefined variable: vars in ...\test.php on line 10 obvious hi DESIRED OUTPUT: hi obvious hi Thanks, dK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file in a class with global/parent scope?
Daniel Kolbo wrote: Hello, I've cleaned up my question a bit. I want the included file which is called within a method of a class to have the same scope as the instantiation of the class's object. That is, i want a class to include a file in the calling object's scope. How would one do this? 'test.php' ?php class CSomeClass { public function cinclude() { include('vars.php'); } } $object = new CSomeClass; $object-cinclude(); echo $vars;//i want this to print 'hi' include('vars.php'); echo obvious $vars; ? 'vars.php' ?php $vars = hi; ? OUTPUT: Notice: Undefined variable: vars in ...\test.php on line 10 obvious hi DESIRED OUTPUT: hi obvious hi Thanks, dK Should get you started: //one way ?php class CSomeClass { public function cinclude() { include('vars.php'); return get_defined_vars(); } } $object = new CSomeClass; $inc_vars = $object-cinclude(); echo $inc_vars['vars'];//i want this to print 'hi' ---or--- //another way ?php class CSomeClass { var $inc_vars; public function cinclude() { include('vars.php'); $this-inc_vars = get_defined_vars(); } } $object = new CSomeClass; $object-cinclude(); echo $object-inc_vars['vars'];//i want this to print 'hi' -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file in a class with global/parent scope?
Shawn McKenzie wrote: Daniel Kolbo wrote: Hello, I've cleaned up my question a bit. I want the included file which is called within a method of a class to have the same scope as the instantiation of the class's object. That is, i want a class to include a file in the calling object's scope. How would one do this? 'test.php' ?php class CSomeClass { public function cinclude() { include('vars.php'); } } $object = new CSomeClass; $object-cinclude(); echo $vars;//i want this to print 'hi' include('vars.php'); echo obvious $vars; ? 'vars.php' ?php $vars = hi; ? OUTPUT: Notice: Undefined variable: vars in ...\test.php on line 10 obvious hi DESIRED OUTPUT: hi obvious hi Thanks, dK Should get you started: //one way ?php class CSomeClass { public function cinclude() { include('vars.php'); return get_defined_vars(); } } $object = new CSomeClass; $inc_vars = $object-cinclude(); echo $inc_vars['vars'];//i want this to print 'hi' ---or--- //another way ?php class CSomeClass { var $inc_vars; public function cinclude() { include('vars.php'); $this-inc_vars = get_defined_vars(); } } $object = new CSomeClass; $object-cinclude(); echo $object-inc_vars['vars'];//i want this to print 'hi' Another way off the top of my head: //vars.php $vars['something'] = 'hi'; $vars['whatever'] = 'bye'; //test.php class CSomeClass { var $vars; public function cinclude() { include('vars.php'); $this-vars = $vars; } } $object = new CSomeClass; $object-cinclude(); echo $object-vars['something'];//i want this to print 'hi' -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include File Errors with Comments
From: Patrick Moloney I have a simple web site with a simple page that all works well, although I have had a similar problem a couple of times that seems to be caused by Comment Lines in the included files. I wonder if I have it entirely right. All my files are .php files, but almost all the code is HTML. The file for my Web page is a complete HTML document, the file is .php. The web page file Includes a few other files by putting the Include statement in PHP tags, all by itself. The problem file contains the menu as the include. I made a change to the menu, that works, but I added a line with a comment at the top, which causes problems. The menu is read like text. The first few lines in my menu file, menu.php, are comments using HTML syntax. The menu file has on UL and LI tags for the menu items - no HTML, BODY etc. So I have a line of PHP in my web page file calling a .php file where the first 2 lines are HTML comments. It was working with 2 comment lines, the failed with 3 lines. Even when it fails the remainder of the page displays ok although it is down lower because of the menu being displayed as text. I remove the comment it works. Does PHP preprocess the file but treat the comments as text because I never said it was HTML? Would PHP comments have to be inside PHP tags? Am I correct in having just a fragment of HTML in the included file without the entire HTML organization? I'd like to have comments in the file. This is one detail that I have not seen a good explanation for. When PHP opens an included file, it defaults back to HTML mode. You must have the PHP tags to force it into PHP mode. This is true no matter what file extension you have on them. So if you want to use PHP style comments, you must wrap them with the proper tags. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include File Errors with Comments
Patrick Moloney wrote: Does PHP preprocess the file but treat the comments as text because I never said it was HTML? I've not had it do that. Would PHP comments have to be inside PHP tags? Yes. If you use a php comment it has to be inside a php tag. One issue I have seen though is xml/xhtml files. php sometimes sees the ?xml and assumes it is a php start tag. I assume the appropriate thing to do is turn off short tags in your php.ini file - but unfortunately a lot of 3rd party classes and apps make heavy use of them. Am I correct in having just a fragment of HTML in the included file without the entire HTML organization? I'd like to have comments in the file. Use html comments and it should be fine - or put php tags around the comments. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include File Errors with Comments
Patrick Moloney wrote: I have a simple web site with a simple page that all works well, although I have had a similar problem a couple of times that seems to be caused by Comment Lines in the included files. I wonder if I have it entirely right. All my files are .php files, but almost all the code is HTML. The file for my Web page is a complete HTML document, the file is .php. The web page file Includes a few other files by putting the Include statement in PHP tags, all by itself. The problem file contains the menu as the include. I made a change to the menu, that works, but I added a line with a comment at the top, which causes problems. The menu is read like text. The first few lines in my menu file, menu.php, are comments using HTML syntax. The menu file has on UL and LI tags for the menu items - no HTML, BODY etc. So I have a line of PHP in my web page file calling a .php file where the first 2 lines are HTML comments. It was working with 2 comment lines, the failed with 3 lines. Even when it fails the remainder of the page displays ok although it is down lower because of the menu being displayed as text. I remove the comment it works. Does PHP preprocess the file but treat the comments as text because I never said it was HTML? Would PHP comments have to be inside PHP tags? Am I correct in having just a fragment of HTML in the included file without the entire HTML organization? I'd like to have comments in the file. If you're putting php comments outside php tags, they are treated as text (they're not inside php tags, it's not php). The php tags tell php when to start parsing/processing the script. Without that, it passes it to your webserver to just display the content. If that's not what you're doing post a short (very short - don't post your whole scripts) example of what you mean. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
At 1:55 PM -0700 5/23/07, Kevin Murphy wrote: .inc files have a disadvantage in that if you view the file: http://www.yoursite.com/file.inc you can see the php code. I prefer not to use those just on the off chance that someone can see my code and use that as the basis for figuring out a way to exploit it (especially true of password files, etc). -- Kevin Murphy And the other side of that coin is if you have your files ending with .php, then they can be called/run directly and do things you may not want done. That's a good reason to use some sort of token protection in your include php files so that they cannot be run directly. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On Fri, 2007-05-25 at 16:17 +0200, Tijnema wrote: On 5/25/07, Edward Kay [EMAIL PROTECTED] wrote: Why are your include files in your web root in the first place? Move them elsewhere on your filesystem and then it's not even possible to access them via the web. Edward Oh, I don't want my web files all over the filesystem, I want to keep all files for a single project inside a single folder on my webserver. So, that if i move them around, I have all files there. I do that, then I run a build script and it migrates all the static content from the CVS to the web tree that can be requested and builds all the pages from the templates to the requestable pages. Everything is in one location from an archival POV, but it all goes into the right slot for visitor consumption :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On 5/25/07, Edward Kay [EMAIL PROTECTED] wrote: -Original Message- From: Tijnema [mailto:[EMAIL PROTECTED] Sent: 25 May 2007 15:00 To: tedd Cc: Kevin Murphy; Stephen; php Subject: Re: [PHP] Include file questions On 5/25/07, tedd [EMAIL PROTECTED] wrote: At 1:55 PM -0700 5/23/07, Kevin Murphy wrote: .inc files have a disadvantage in that if you view the file: http://www.yoursite.com/file.inc you can see the php code. I prefer not to use those just on the off chance that someone can see my code and use that as the basis for figuring out a way to exploit it (especially true of password files, etc). -- Kevin Murphy And the other side of that coin is if you have your files ending with .php, then they can be called/run directly and do things you may not want done. That's a good reason to use some sort of token protection in your include php files so that they cannot be run directly. Cheers, tedd It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema Why are your include files in your web root in the first place? Move them elsewhere on your filesystem and then it's not even possible to access them via the web. Edward Oh, I don't want my web files all over the filesystem, I want to keep all files for a single project inside a single folder on my webserver. So, that if i move them around, I have all files there. Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On Fri, 2007-05-25 at 16:00 +0200, Tijnema wrote: On 5/25/07, tedd [EMAIL PROTECTED] wrote: At 1:55 PM -0700 5/23/07, Kevin Murphy wrote: .inc files have a disadvantage in that if you view the file: http://www.yoursite.com/file.inc you can see the php code. I prefer not to use those just on the off chance that someone can see my code and use that as the basis for figuring out a way to exploit it (especially true of password files, etc). -- Kevin Murphy And the other side of that coin is if you have your files ending with .php, then they can be called/run directly and do things you may not want done. That's a good reason to use some sort of token protection in your include php files so that they cannot be run directly. Cheers, tedd It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema Yep, same with me. Only runnable code is in the config file that gets run every page anyways and in the pages that get requested themselves. At any rate, anything that shouldn't be requested is outside the web tree. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On 5/25/07, tedd [EMAIL PROTECTED] wrote: At 1:55 PM -0700 5/23/07, Kevin Murphy wrote: .inc files have a disadvantage in that if you view the file: http://www.yoursite.com/file.inc you can see the php code. I prefer not to use those just on the off chance that someone can see my code and use that as the basis for figuring out a way to exploit it (especially true of password files, etc). -- Kevin Murphy And the other side of that coin is if you have your files ending with .php, then they can be called/run directly and do things you may not want done. That's a good reason to use some sort of token protection in your include php files so that they cannot be run directly. Cheers, tedd It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include file questions
-Original Message- From: Tijnema [mailto:[EMAIL PROTECTED] Sent: 25 May 2007 15:00 To: tedd Cc: Kevin Murphy; Stephen; php Subject: Re: [PHP] Include file questions On 5/25/07, tedd [EMAIL PROTECTED] wrote: At 1:55 PM -0700 5/23/07, Kevin Murphy wrote: .inc files have a disadvantage in that if you view the file: http://www.yoursite.com/file.inc you can see the php code. I prefer not to use those just on the off chance that someone can see my code and use that as the basis for figuring out a way to exploit it (especially true of password files, etc). -- Kevin Murphy And the other side of that coin is if you have your files ending with .php, then they can be called/run directly and do things you may not want done. That's a good reason to use some sort of token protection in your include php files so that they cannot be run directly. Cheers, tedd It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema Why are your include files in your web root in the first place? Move them elsewhere on your filesystem and then it's not even possible to access them via the web. Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include file questions
-Original Message- From: Tijnema [mailto:[EMAIL PROTECTED] It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema Why are your include files in your web root in the first place? Move them elsewhere on your filesystem and then it's not even possible to access them via the web. Edward Oh, I don't want my web files all over the filesystem, I want to keep all files for a single project inside a single folder on my webserver. So, that if i move them around, I have all files there. Tijnema This is exactly what I do - one folder per project. You just have you web-root as a sub folder in this, eg: /project /includes - nicely protected /public_html - web root /images index.php ... ... Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On 5/25/07, Edward Kay [EMAIL PROTECTED] wrote: -Original Message- From: Tijnema [mailto:[EMAIL PROTECTED] It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema Why are your include files in your web root in the first place? Move them elsewhere on your filesystem and then it's not even possible to access them via the web. Edward Oh, I don't want my web files all over the filesystem, I want to keep all files for a single project inside a single folder on my webserver. So, that if i move them around, I have all files there. Tijnema This is exactly what I do - one folder per project. You just have you web-root as a sub folder in this, eg: /project /includes - nicely protected /public_html - web root /images index.php ... ... Edward Hmm, way too complicated :P I like to keep it simple, just like this: / /data /http /project1 /includes config.php With passwords :P /images /project2 /includes Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On Fri, 2007-05-25 at 17:07 +0200, Tijnema wrote: On 5/25/07, Edward Kay [EMAIL PROTECTED] wrote: -Original Message- From: Tijnema [mailto:[EMAIL PROTECTED] It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema Why are your include files in your web root in the first place? Move them elsewhere on your filesystem and then it's not even possible to access them via the web. Edward Oh, I don't want my web files all over the filesystem, I want to keep all files for a single project inside a single folder on my webserver. So, that if i move them around, I have all files there. Tijnema This is exactly what I do - one folder per project. You just have you web-root as a sub folder in this, eg: /project /includes - nicely protected /public_html - web root /images index.php ... ... Edward Hmm, way too complicated :P I like to keep it simple, just like this: / /data /http /project1 /includes config.php With passwords :P /images /project2 /includes You won't like mine then :) /wherever /Project /bin /build /source /static /templates patterns.txt /compilers /configs /cron /functions /modules /services /sql buildSite.php* config.interjinn.php@ (link to active config in /configs) Running buildSite.php (which uses patterns.txt) generates the webtree: /wherever /DOC_ROOT Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 17:07 +0200, Tijnema wrote: On 5/25/07, Edward Kay [EMAIL PROTECTED] wrote: -Original Message- From: Tijnema [mailto:[EMAIL PROTECTED] It's just the way you write script, my included files contain only functions variables, no executing code. 99% I have a class around it. If you write it like that, than there's no problem with execution the included file directly, as it loads the class but doesn't do anything with it :) Tijnema Why are your include files in your web root in the first place? Move them elsewhere on your filesystem and then it's not even possible to access them via the web. Edward Oh, I don't want my web files all over the filesystem, I want to keep all files for a single project inside a single folder on my webserver. So, that if i move them around, I have all files there. Tijnema This is exactly what I do - one folder per project. You just have you web-root as a sub folder in this, eg: /project /includes - nicely protected /public_html - web root /images index.php ... ... Edward Hmm, way too complicated :P I like to keep it simple, just like this: / /data /http /project1 /includes config.php With passwords :P /images /project2 /includes You won't like mine then :) /wherever /Project /bin /build /source /static /templates patterns.txt /compilers /configs /cron /functions /modules /services /sql buildSite.php* config.interjinn.php@ (link to active config in /configs) Running buildSite.php (which uses patterns.txt) generates the webtree: /wherever /DOC_ROOT Cheers, Rob. Definitely not.! also way too complicated... :P Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 18:04 +0200, Tijnema wrote: On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 17:07 +0200, Tijnema wrote: I like to keep it simple, just like this: / /data /http /project1 /includes config.php With passwords :P /images /project2 /includes You won't like mine then :) /wherever /Project /bin /build /source /static /templates patterns.txt /compilers /configs /cron /functions /modules /services /sql buildSite.php* config.interjinn.php@ (link to active config in /configs) Running buildSite.php (which uses patterns.txt) generates the webtree: /wherever /DOC_ROOT Cheers, Rob. Definitely not.! also way too complicated... :P Tijnema I think the word you're looking for is organized ;) Cheers, Rob. -- Do you call your code organized? Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On Fri, 2007-05-25 at 18:04 +0200, Tijnema wrote: On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 17:07 +0200, Tijnema wrote: I like to keep it simple, just like this: / /data /http /project1 /includes config.php With passwords :P /images /project2 /includes You won't like mine then :) /wherever /Project /bin /build /source /static /templates patterns.txt /compilers /configs /cron /functions /modules /services /sql buildSite.php* config.interjinn.php@ (link to active config in /configs) Running buildSite.php (which uses patterns.txt) generates the webtree: /wherever /DOC_ROOT Cheers, Rob. Definitely not.! also way too complicated... :P Tijnema I think the word you're looking for is organized ;) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On Fri, 2007-05-25 at 18:20 +0200, Tijnema wrote: On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 18:04 +0200, Tijnema wrote: On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 17:07 +0200, Tijnema wrote: I like to keep it simple, just like this: / /data /http /project1 /includes config.php With passwords :P /images /project2 /includes You won't like mine then :) /wherever /Project /bin /build /source /static /templates patterns.txt /compilers /configs /cron /functions /modules /services /sql buildSite.php* config.interjinn.php@ (link to active config in /configs) Running buildSite.php (which uses patterns.txt) generates the webtree: /wherever /DOC_ROOT Cheers, Rob. Definitely not.! also way too complicated... :P Tijnema I think the word you're looking for is organized ;) Cheers, Rob. -- Do you call your code organized? Very. Each directory contains very specific types of code/content. Tracking down where any given function, class, custom tag, behaviour, etc is defined is extremely simple. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 18:20 +0200, Tijnema wrote: On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 18:04 +0200, Tijnema wrote: On 5/25/07, Robert Cummings [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 17:07 +0200, Tijnema wrote: I like to keep it simple, just like this: / /data /http /project1 /includes config.php With passwords :P /images /project2 /includes You won't like mine then :) /wherever /Project /bin /build /source /static /templates patterns.txt /compilers /configs /cron /functions /modules /services /sql buildSite.php* config.interjinn.php@ (link to active config in /configs) Running buildSite.php (which uses patterns.txt) generates the webtree: /wherever /DOC_ROOT Cheers, Rob. Definitely not.! also way too complicated... :P Tijnema I think the word you're looking for is organized ;) Cheers, Rob. -- Do you call your code organized? Very. Each directory contains very specific types of code/content. Tracking down where any given function, class, custom tag, behaviour, etc is defined is extremely simple. Cheers, Rob. I don't agree with you, i have includes in includes dir inside my project, images in images, etc. classes in includes dir start with class. configuration files in includes start with config. etc. But, this is all about personal preference ;) I like the way I do it, you like the way you do it... Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
Stephen escribió: 1) Does the filename extension matter? I prefer *.inc? It seems to work fine, but I only see others using *.php 2) Does the include file need an opening ?php and ending ? ? Not big issues, but I am curious. Thanks Stephen If you use .inc extension you will have to modify the apache so they do not show: RedirectMatch 404 /^.*\.(inc)$/ Thus, if you try to access the file using the navigator it will show a Page not found error :-D -- Miguel J. Jiménez Programador Senior Área de Internet/XSL/PHP [EMAIL PROTECTED] ISOTROL Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. Parque Tecnológico Cartuja '93, 41092 Sevilla (ESP). Teléfono: +34 955 036 800 - Fax: +34 955 036 849 http://www.isotrol.com You let a political fight come between you and your best friend you have in all the world. Do you realize how foolish that is? How ominous? How can this country survive if friends can't rise above the quarrel. Constance Hazard, North South (book I) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
On Wed, May 23, 2007 3:48 pm, Stephen wrote: 1) Does the filename extension matter? I prefer *.inc? It seems to work fine, but I only see others using *.php From a strictly will it work stand-point, the extension can be anything you want or none at all. HOWEVER, there are various security code privacy issues revolving around the chosen extension. The point being that you probably don't want your code exposed to the world, nor executed out of context, most likely. Some will configure Apache to not serve up .inc files. Others will add .php on the end, and [try to] make sure that the code does nothing bad if executed out of context. I personally think one should just move the include files out of the web tree and use http://php.net/set_include_path (or similar php.ini settings) to make it impossible for the code to have any chance at all of being served up as plain text or getting executed out of sequence. 2) Does the include file need an opening ?php and ending ? ? Yes. PHP jumps back to HTML mode for each include file, because Rasmus liked it that way back in 1995... Or he couldn't figure out how to make it work the other way around... Or whatever. It is the way it is. And technically, the closing ? is optional, which some consider a Feature. YMMV -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file questions
Kevin Murphy [EMAIL PROTECTED] wrote: .inc files have a disadvantage in that if you view the file: http://www.yoursite.com/file.inc you can see the php code. I prefer not to use those just on the off chance that someone can see my code and use that as the basis for figuring out a way to exploit it (especially true of password files, etc). I have a directory at the same level as Doc Root called include and all my includes are in there. These contains login data, passwords etc. I feel safer keeping as much of my code as possible outside of Doc Root. Stephen
Re: [PHP] Include file path.. please help im newby
StainOnRug wrote: Hello I am a beginner at PHP. I searched for my ? but couldn’t pinpoint it.. My question is, How do I upload include files onto my website include directory. Im hosted through Yahoo, I am not running a server on my computer. When I check out my PHP info it tells me the include dir is include path .:/include:/usr/lib/php.. how do I acess this folder to put files in it so that I can take advantage of the include functions on my PHP scripts. Thank you sooo much! you can change the include_path definition in your script. you can also include files which live in other directories than those defined in the include_path ini setting. I doubt you are allowed to upload any files to /include or /usr/lib/php, so your recourse is to create your 'include' directory somewhere where you can upload stuff to and then optionally redefine include_path to point to your personal 'include' dir, something like: ini_set('include_path', ini_get('include_path').':/path/to/your/personal/inc/dir'); see also Peter's comments in his reply to your post. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include file path.. please help im newby
Include path and include() function is different things. Include path: this is paths where PHP will look for files tried to be included if it doesn't exist in script directory. If you do include(afile.php) and afile.php doesn't exist in the same directory as where your script that is calling the include is. Then it will first look in . /include /usr/lib/php Take a look here http://www.php.net/include to read more about the include function in PHP. Best regards, Peter Lauri www.dwsasia.com - company web site www.lauri.se - personal web site www.carbonfree.org.uk - become Carbon Free -Original Message- From: StainOnRug [mailto:[EMAIL PROTECTED] Sent: Sunday, February 25, 2007 12:57 AM To: php-general@lists.php.net Subject: [PHP] Include file path.. please help im newby Hello I am a beginner at PHP. I searched for my ? but couldn't pinpoint it.. My question is, How do I upload include files onto my website include directory. Im hosted through Yahoo, I am not running a server on my computer. When I check out my PHP info it tells me the include dir is include path .:/include:/usr/lib/php.. how do I acess this folder to put files in it so that I can take advantage of the include functions on my PHP scripts. Thank you sooo much! -- View this message in context: http://www.nabble.com/Include-file-path..-please-help-im-newby-tf3285344.htm l#a9138696 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
Richard Lynch wrote: On Sat, February 3, 2007 7:05 pm, Eli wrote: Does any included file in PHP have a unique identifier? (like a stack of includes identifier). Down in the guts of PHP source, there may be some kind of file handler which is unique... Actually, that's what I need. I want to know which instance of the file is running.. __FILE__ only gives the filename, but if the file is included in itself, there's no way to distinct which instance of them is currently running.. The base reason for this is storing some extra environment data on each file included.. -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
On 2/5/07, Richard Lynch [EMAIL PROTECTED] wrote: If you want to avoid the overhead of include_once, it's a pretty common practice (borrowed from C .h files) to do: Just out of curiosity, how much additional overhead are we talking about? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
On Mon, February 5, 2007 10:09 am, Craige Leeder wrote: On 2/5/07, Richard Lynch [EMAIL PROTECTED] wrote: If you want to avoid the overhead of include_once, it's a pretty common practice (borrowed from C .h files) to do: Just out of curiosity, how much additional overhead are we talking about? What version of PHP are we talking about? In its early days, it was very expensive, particularly if your code-base grew very large... Later, it was only expensive if your client was doing something whack like dynamically including hundreds of file snippets. (Don't ask.) These days, I would hazard a guess that it's as optimized as it can be, really, but you'd have to test and read source to be sure. Note that in all cases, the performance issue kicked in when you were including LOTS of different files, as the search space for what was already included grew. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
On Sat, February 3, 2007 7:05 pm, Eli wrote: Does any included file in PHP have a unique identifier? (like a stack of includes identifier). Down in the guts of PHP source, there may be some kind of file handler which is unique... But nothing I'm aware of exposes this to ?php ? code in any way, other than http://php.net/include_once If the files names are different, then __FILE__ can be used as an identifier. But if a file was included by itself, then __FILE__ is the same, tho there are 2 different includes of the same file. Example: === a.php ?php echo \nRunning .__FILE__. (id=X)!\t; if (!$visited) { echo You are visiting here!; $visited = true; include(__FILE__); } else { echo You have been already visiting here! (Bye); } ? -thanks, Eli If you want to avoid the overhead of include_once, it's a pretty common practice (borrowed from C .h files) to do: if (!defined('FILENAME')){ define('FILENAME', 1); //rest of code here } It is entirely up to YOU to make sure FILENAME is unique for your application/project... Which can become problematic when integrating large packages. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
On Sun, 2007-02-04 at 03:05 +0200, Eli wrote: Hello, Does any included file in PHP have a unique identifier? (like a stack of includes identifier). If the files names are different, then __FILE__ can be used as an identifier. But if a file was included by itself, then __FILE__ is the same, tho there are 2 different includes of the same file. Example: === a.php ?php echo \nRunning .__FILE__. (id=X)!\t; if (!$visited) { echo You are visiting here!; $visited = true; include(__FILE__); } else { echo You have been already visiting here! (Bye); } ? Looking at the code above... it would seem you want: include_once() Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
Robert Cummings wrote: Looking at the code above... it would seem you want: include_once() It's not the idea.. I'm not trying to make that code work, I want to know which exact include (of the same file) does what.. Say you got a loop of self-include: e.g: === a.php ?php echo \nRunning .__FILE__. (id=X)!\t; if ($visited5) { echo You are visiting here!; $visited++; include(__FILE__); } else { echo That's enough! Bye!; } ? In (id=X)!.. what's the X? You may say you can use $visited as an identifier, but it's not the point I mean.. I want a global include file identifier, that is not dependent on other variables. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
On Saturday 03 February 2007 7:27 pm, Eli wrote: Robert Cummings wrote: Looking at the code above... it would seem you want: include_once() It's not the idea.. I'm not trying to make that code work, I want to know which exact include (of the same file) does what.. Huh? Say you got a loop of self-include: e.g: === a.php ?php echo \nRunning .__FILE__. (id=X)!\t; if ($visited5) { echo You are visiting here!; $visited++; include(__FILE__); } else { echo That's enough! Bye!; } ? In (id=X)!.. what's the X? You may say you can use $visited as an identifier, but it's not the point I mean.. I want a global include file identifier, that is not dependent on other variables. realpath(__FILE__) will give you the absolute path on the server of the current file, which is unique. Why you want that for what you're doing I have no idea, but it's the only unique identifier I can think of that isn't a variable or constant. (Well, it is a constant, but you get the idea. I suppose.) The fact that you even want something like that, however, scares me. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
On Sun, 2007-02-04 at 03:27 +0200, Eli wrote: Robert Cummings wrote: Looking at the code above... it would seem you want: include_once() It's not the idea.. I'm not trying to make that code work, I want to know which exact include (of the same file) does what.. Say you got a loop of self-include: e.g: === a.php ?php echo \nRunning .__FILE__. (id=X)!\t; if ($visited5) { echo You are visiting here!; $visited++; include(__FILE__); } else { echo That's enough! Bye!; } ? In (id=X)!.. what's the X? You may say you can use $visited as an identifier, but it's not the point I mean.. I want a global include file identifier, that is not dependent on other variables. Make one... ?php if( !isset( $GLOBALS['include_counter'][__FILE__] ) ) { $GLOBALS['include_counter'][__FILE__] = 1; } else { $GLOBALS['include_counter'][__FILE__]++; } echo \nRunning .__FILE__. (id=X)!\t; if( $GLOBALS['include_counter'][__FILE__] 5 ) { echo You are visiting here!; include(__FILE__); } else { echo That's enough! Bye!; } ? The actual counter stuff could be put in a function which could be in an include file you load so that you do the following at the top: ?php include( 'someFunctions.php' ); register_include( __FILE__ ); ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file error, common one I think
Hi, I have used this file in my index file. When I run this file separately it shows the random image but not when I include on my index.php. Thanks in advance, João Cândido de Souza Neto wrote: Is it the whole code of your file, or is there any other html code? Chris Carter [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi, Here is code that I got from the internet for random image. This file works perfect if I try it independently but not on any existing file. I think the error that I am getting is quite common on the net but its new for me. I am getting this error: Warning: Cannot modify header information - headers already sent by (output started at /folder/test.php:12) in /folder/randomimage.php on line 19 the code that I got from net: ? $folder = 'images/'; $exts = 'jpg jpeg png gif'; $files = array(); $i = -1; if ('' == $folder) $folder = './'; $handle = opendir($folder); $exts = explode(' ', $exts); while (false !== ($file = readdir($handle))) { foreach($exts as $ext) { if (preg_match('/\.'.$ext.'$/i', $file, $test)) { $files[] = $file; ++$i; } } } closedir($handle); mt_srand((double)microtime()*100); $rand = mt_rand(0, $i); Line 19 is below: header('Location: '.$folder.$files[$rand]); ? Thanks a bunch. Chris -- View this message in context: http://www.nabble.com/Include-file-error%2C-common-one-I-think-tf2971907.html#a8316202 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- View this message in context: http://www.nabble.com/Include-file-error%2C-common-one-I-think-tf2971907.html#a8316921 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file error, common one I think
Chris Carter wrote: Hi, I have used this file in my index file. When I run this file separately it shows the random image but not when I include on my index.php. your image script shouldn't be included in your [index] page. instead it should be referenced by the src attribute of an img tag that your [index] page outputs e.g. in your [index] page have a line something like: echo 'img src=/randomimage.php alt= /'; Thanks in advance, João Cândido de Souza Neto wrote: Is it the whole code of your file, or is there any other html code? Chris Carter [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi, Here is code that I got from the internet for random image. This file works perfect if I try it independently but not on any existing file. I think the error that I am getting is quite common on the net but its new for me. I am getting this error: Warning: Cannot modify header information - headers already sent by (output started at /folder/test.php:12) in /folder/randomimage.php on line 19 the code that I got from net: ? $folder = 'images/'; $exts = 'jpg jpeg png gif'; $files = array(); $i = -1; if ('' == $folder) $folder = './'; $handle = opendir($folder); $exts = explode(' ', $exts); while (false !== ($file = readdir($handle))) { foreach($exts as $ext) { if (preg_match('/\.'.$ext.'$/i', $file, $test)) { $files[] = $file; ++$i; } } } closedir($handle); mt_srand((double)microtime()*100); $rand = mt_rand(0, $i); Line 19 is below: header('Location: '.$folder.$files[$rand]); ? Thanks a bunch. Chris -- View this message in context: http://www.nabble.com/Include-file-error%2C-common-one-I-think-tf2971907.html#a8316202 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file error, common one I think
At 9:44 AM -0800 1/13/07, Chris Carter wrote: Hi, Here is code that I got from the internet for random image. This file works perfect if I try it independently but not on any existing file. I think the error that I am getting is quite common on the net but its new for me. I am getting this error: Warning: Cannot modify header information - headers already sent by (output started at /folder/test.php:12) in /folder/randomimage.php on line 19 Chris : Whenever I get that error, I look to: http://us2.php.net/ob_start I think ob_start and ob_flush might solve your problem. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file error, common one I think
I am not sure about this but the requirement is that even the links associated with the image changes with the image. Like an image of restaurant links to restaurants page and image for pubs links to pubs page. Is this achievable through this code. I could not test it coz it was not working. Can you help!!! Thanks, Jochem Maas wrote: Chris Carter wrote: Hi, I have used this file in my index file. When I run this file separately it shows the random image but not when I include on my index.php. your image script shouldn't be included in your [index] page. instead it should be referenced by the src attribute of an img tag that your [index] page outputs e.g. in your [index] page have a line something like: echo ' /randomimage.php '; Thanks in advance, João Cândido de Souza Neto wrote: Is it the whole code of your file, or is there any other html code? Chris Carter [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi, Here is code that I got from the internet for random image. This file works perfect if I try it independently but not on any existing file. I think the error that I am getting is quite common on the net but its new for me. I am getting this error: Warning: Cannot modify header information - headers already sent by (output started at /folder/test.php:12) in /folder/randomimage.php on line 19 the code that I got from net: ? $folder = 'images/'; $exts = 'jpg jpeg png gif'; $files = array(); $i = -1; if ('' == $folder) $folder = './'; $handle = opendir($folder); $exts = explode(' ', $exts); while (false !== ($file = readdir($handle))) { foreach($exts as $ext) { if (preg_match('/\.'.$ext.'$/i', $file, $test)) { $files[] = $file; ++$i; } } } closedir($handle); mt_srand((double)microtime()*100); $rand = mt_rand(0, $i); Line 19 is below: header('Location: '.$folder.$files[$rand]); ? Thanks a bunch. Chris -- View this message in context: http://www.nabble.com/Include-file-error%2C-common-one-I-think-tf2971907.html#a8316202 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- View this message in context: http://www.nabble.com/Include-file-error%2C-common-one-I-think-tf2971907.html#a8331510 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file path errors
At 6:15 PM +0900 4/8/06, kmh496 wrote: hi, my webroot is /a/b/current/ i am in /a/b/current/d/file.php file.php has a line require_once ($_SERVER[document_root]./d/common.php); it finds the file, but the variables inside common.php are not set and don't exist in file.php where is my mistake? Probably in your links -- the methodology should work. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file to global scope
Claudio wrote: Hi, I'm using PHP 5. I have a class operation that includes php files. Is there a way to include this files to global scope? So that difined vars and functions are global accesseble? first off I would recommend that you 'pollute' your global scope as little as possible. secondly could you describe what you are trying to do and why exactly - stuff like this has been solved before but its hard to recommend a strategy when one doesn't know what the underlying idea/direction is that said the solution will probably involve the use of the 'global' keyword. I saw that some PHP functions have a context parameter, is something like this in eval or include possible? I think you mean then 'context' param related to functions that work with streams - this is not AFAIK related to [variable] 'scope'. also eval() sucks (unless there is no other way to do something, in which case its lovely ;-). Thanks, Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file to global scope
first off I would recommend that you 'pollute' your global scope as little as possible. I agree at all! Thats my opinion, and i don't use global variables at all. The problem is, other people do. And if I need to use their code I must include it. that said the solution will probably involve the use of the 'global' keyword. Yes, see example files 1 and 2. This files are very simple, but shows the problem. Naturly the decision what file to include an when is complexer than that. The file2.php represents a large standalone old php file. Doesn't maintend by me. It works fine. The file1.php5 represents a newer application. File2 will not work, because $abc is not a global var. Ok, I could search for all declared vars and add a global to it. Thats not realy a nice solution. Do anyone have a better Idea? Claudio file1.php5: - ?php class testInc { public static function incFile($x) { return include_once($x); } } testInc::incFile('file2.php'); ? - file2.php: - ?php $abc = true; function anotherOne() { global $abc; if ($abc) { echo 'it works'; } else { echo 'failure'; } } anotherOne(); ? - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file to global scope
Is it possible to process the file in second php instance? An only get its output? Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file to global scope
Claudio wrote: Is it possible to process the file in second php instance? An only get its output? yes - but its heavy to do (which ever way you do it). basically you need to either call a commandline php script via exec() (or something similar) e.g. exec('php /path/2/your/script.php'); // read the manual to // find out how to get you output/data or also go through the command line and use a tool like 'wget' to call another url e.g: exec('wget http://domain.com/script.php'); OR you could use file_get_contents() (or something similar to do what wget does directly from within php $output = file_get_contents('http://domain.com/script.php'); lots of possibilities - given what you are trying to do I doubt that any possiblity is optimal - shoehorning other applications into your own as standalone modules is an art form ;-) Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file and problems with headers
Make sure you don't have any blankspace before or after the ?php ... ? in your stats.php file. That's usually what does it. On Sat, 21 May 2005, Ross wrote: I have the folowing code which checks whether the user has logged in. if (!isset ($_SESSION['new_session'] ) ) { $login_status = div class=\standard_text\Your are not signed in /div; } if (isset ($_SESSION['new_session'] ) ) { $address = $_SESSION['new_session']; $login_status = div class=\standard_text\Your are signed in as span class=\under\$address/span/div; } ? Now when I have this as a file to be included in each page, status.php (see code) gives the header error (already sent). ?php session_start(); include('status.php'); When the code is pasted in each individual page it works fine. This is no big deal but it is annoying me! why does this not work. I have also tried require_once include_once() but nothin works. Later on in the page there is a form which sets some cookies and uses php_self() to send the data to itself. Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file and problems with headers
On Sat, 2005-05-21 at 06:30, Ross wrote: I have the folowing code which checks whether the user has logged in. if (!isset ($_SESSION['new_session'] ) ) { $login_status = div class=\standard_text\Your are not signed in /div; } if (isset ($_SESSION['new_session'] ) ) { $address = $_SESSION['new_session']; $login_status = div class=\standard_text\Your are signed in as span class=\under\$address/span/div; } ? Now when I have this as a file to be included in each page, status.php (see code) gives the header error (already sent). ?php session_start(); include('status.php'); How about putting session_start in status.php then just include it. ?php session_start(); if (!isset ($_SESSION['new_session'] ) ) { $login_status = div class=\standard_text\Your are not signed in /div; } if (isset ($_SESSION['new_session'] ) ) { $address = $_SESSION['new_session']; $login_status = div class=\standard_text\Your are signed in as span class=\under\$address/span/div; } echo $login_status; ? Then in other files just: ?php include 'status.php'; ? -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
On Wed, March 30, 2005 2:31 pm, [EMAIL PROTECTED] said: ...Scripts using single quotes run slightly faster because the PHP parser can include the string directly. Double quoted strings are slower because they need to be parsed This is PATENTLY FALSE, at least in part. PHP *must* parse single-quoted strings to find: \' \\ because those can be embedded in single-quoted strings to indicate apostrophe and backslash. Double-quotes merely increases the number of character-combinations to be checked, not the algorithm to check for them. [Okay, double-quotes *might* require a two-character look-ahead buffer instead of one... But I doubt it.] Show us your query benchmark -- Every benchmark with source / methodology posted is showing the above statement to be WRONG. YOUR benchmark is presented without source, without methodology. If you don't provide those, it's not a benchmark, it's VooDoo. :-) Nobody will (or should) believe it. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
This way is faster: include('..includes/' . $include); Its always better to avoid using doublequotes. meatbread. On Tue, 29 Mar 2005 20:55:17 -0500, James Pancoast [EMAIL PROTECTED] wrote: Try it with double quotes instead: include( ../includes/$include ); That way works for me. And I also hope you're cleansing or filtering $include in some way. On Tue, 29 Mar 2005 19:41:15 -0600, Marquez Design [EMAIL PROTECTED] wrote: Does anyone know how to include a variable page? The variable is a page name. Such as inluded_file.html Include ('../includes/$include'); Does not seem to work. Thanks! -- Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include file
[snip] This way is faster: include('..includes/' . $include); Its always better to avoid using doublequotes. [/snip] Why is it faster? And why should you avoid using double quotes? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
Why is it faster? And why should you avoid using double quotes? ...Scripts using single quotes run slightly faster because the PHP parser can include the string directly. Double quoted strings are slower because they need to be parsed Quoted from: http://www.zend.com/zend/tut/using-strings.php?article=using-stringskind=tid=1399open=1anc=0view=1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include file
[snip] Personally, I go almost exclusively with double quotes, so I'm interested to see how your include is faster. include('..includes/' . $include); Jay Blanchard [EMAIL PROTECTED] 03/30/2005 02:58 PM To:xfedex [EMAIL PROTECTED], php-general@lists.php.net cc: Subject:RE: [PHP] Include file [snip] This way is faster: include('..includes/' . $include); Its always better to avoid using doublequotes. [/snip] Why is it faster? And why should you avoid using double quotes? [/snip] 1. Always reply to the list ('reply-all') B. It's hard to read in context. Why? Top-posting is bad. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include file
[snip] Why is it faster? And why should you avoid using double quotes? ...Scripts using single quotes run slightly faster because the PHP parser can include the string directly. Double quoted strings are slower because they need to be parsed Quoted from: http://www.zend.com/zend/tut/using-strings.php?article=using-stringskin d=tid=1399open=1anc=0view=1 [/snip] I try to use both types of quotes in the proper circumstance. Having said that, I came to computing in the age where we worried over CPU cycles, but I don't see how in this day and age the difference between the two would even matter. Even on a high load site the difference between the two would be negligible. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
Jay Blanchard wrote: snip I try to use both types of quotes in the proper circumstance. Having said that, I came to computing in the age where we worried over CPU cycles, but I don't see how in this day and age the difference between the two would even matter. Even on a high load site the difference between the two would be negligible. Let's see if you still say that after you run your php scripts on my Atari 800XL. ;) -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
On Wed, 30 Mar 2005 15:14:27 -0600, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] Why is it faster? And why should you avoid using double quotes? ...Scripts using single quotes run slightly faster because the PHP parser can include the string directly. Double quoted strings are slower because they need to be parsed Quoted from: http://www.zend.com/zend/tut/using-strings.php?article=using-stringskin d=tid=1399open=1anc=0view=1 [/snip] I try to use both types of quotes in the proper circumstance. Having said that, I came to computing in the age where we worried over CPU cycles, but I don't see how in this day and age the difference between the two would even matter. Even on a high load site the difference between the two would be negligible. Welli have a 30k script, with double i get 8 or 9 seconds, with sigle i get 0.05 or 0.08 seconds. The script basically made a lot of querys, its part of a user manager module of a system im writing. Remember, the hole world is not US or EUi live in argentina and my web server is a PIII 550Mhz 128mb and if you count that almost the half of the people got a 56k dialup connectionI think that in some cases it does make difference. sorry my englishtoo taired to worry meatbread. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [PHP] Include file
Jay Blanchard wrote: I try to use both types of quotes in the proper circumstance. Having said that, I came to computing in the age where we worried over CPU cycles, but I don't see how in this day and age the difference between the two would even matter. Even on a high load site the difference between the two would be negligible. This has been talked about on this list so many times. Another way to put it would be: ...because in most real-world scripts, the execution time for this kind of operation (the string parsing) is negligible compared to the script's total execution time. So even if you could reduce the time it took to parse strings to nothing, you wouldn't speed up the total execution time very much. If you want to optimize the performance of your scripts, there are probably a lot of other things that should be much higher on your priority list than substituting double quotes with single quotes. /Mattias Thorslund -- More views at http://www.thorslund.us -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
Because I'm bored, I decided to test the theory. AMD 3200xp 1.5gb Memory RHEL AS 3 I ran the test 20 times, and 18 of those times, double quotes were faster than single quotes. Don't always trust what you read. Not to mention the fact that the 'faster' of the two was 'faster' by an average of less than .003 seconds to include 1000 files. ?php function microtime_float() { list ( $usec, $sec ) = explode ( , microtime() ); return ( ( float ) $usec + ( float ) $sec ); } for ( $i = 0; $i 1000; $i++ ) { $fp = fopen ( file_ . $i . .php, w ); fwrite ( $fp, ?php\n\n\n? ); fclose ( $fp ); } $single_start = microtime_float(); for ( $i = 0; $i 1000; $i++ ) { include ( 'file_' . $i . '.php' ); } $single_end = microtime_float(); $double_start = microtime_float(); for ( $i = 0; $i 1000; $i++ ) { include ( file_ . $i . .php ); } $double_end = microtime_float(); $single = $single_end - $single_start; $double = $double_end - $double_start; echo ( Single Quotes : . $single . seconds.br /\n ); echo ( Double Quotes : . $double . seconds.br /br /\n ); if ( $double $single ) { $time = $double - $single; echo ( Single Quotes are . $time . seconds faster than double quotes. ); } else { $time = $single - $double; echo ( Double Quotes are . $time . seconds faster than single quotes. ); } ? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
xfedex wrote: Welli have a 30k script, with double i get 8 or 9 seconds, with sigle i get 0.05 or 0.08 seconds. The script basically made a lot of querys, its part of a user manager module of a system im writing. Could the speed have more to do with whatever database server you are using, than with PHP? I assume database since you are querying something. Just curious. And Jay: I'm using Lotus Notes R6, not much I can do about top quoting. Martin Austin xfedex [EMAIL PROTECTED] 03/30/2005 06:27 PM Please respond to xfedex To: php-general@lists.php.net cc: Subject:Re: [PHP] Include file On Wed, 30 Mar 2005 15:14:27 -0600, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] Why is it faster? And why should you avoid using double quotes? ...Scripts using single quotes run slightly faster because the PHP parser can include the string directly. Double quoted strings are slower because they need to be parsed Quoted from: http://www.zend.com/zend/tut/using-strings.php?article=using-stringskin d=tid=1399open=1anc=0view=1 [/snip] I try to use both types of quotes in the proper circumstance. Having said that, I came to computing in the age where we worried over CPU cycles, but I don't see how in this day and age the difference between the two would even matter. Even on a high load site the difference between the two would be negligible. Welli have a 30k script, with double i get 8 or 9 seconds, with sigle i get 0.05 or 0.08 seconds. The script basically made a lot of querys, its part of a user manager module of a system im writing. Remember, the hole world is not US or EUi live in argentina and my web server is a PIII 550Mhz 128mb and if you count that almost the half of the people got a 56k dialup connectionI think that in some cases it does make difference. sorry my englishtoo taired to worry meatbread. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
On Wed, 30 Mar 2005 16:45:32 -0500, John Nichel [EMAIL PROTECTED] wrote: Because I'm bored, I decided to test the theory. AMD 3200xp 1.5gb Memory RHEL AS 3 I ran the test 20 times, and 18 of those times, double quotes were faster than single quotes. Don't always trust what you read. Not to mention the fact that the 'faster' of the two was 'faster' by an average of less than .003 seconds to include 1000 files. ?php function microtime_float() { list ( $usec, $sec ) = explode ( , microtime() ); return ( ( float ) $usec + ( float ) $sec ); } for ( $i = 0; $i 1000; $i++ ) { $fp = fopen ( file_ . $i . .php, w ); fwrite ( $fp, ?php\n\n\n? ); fclose ( $fp ); } $single_start = microtime_float(); for ( $i = 0; $i 1000; $i++ ) { include ( 'file_' . $i . '.php' ); } $single_end = microtime_float(); $double_start = microtime_float(); for ( $i = 0; $i 1000; $i++ ) { include ( file_ . $i . .php ); } $double_end = microtime_float(); $single = $single_end - $single_start; $double = $double_end - $double_start; echo ( Single Quotes : . $single . seconds.br /\n ); echo ( Double Quotes : . $double . seconds.br /br /\n ); if ( $double $single ) { $time = $double - $single; echo ( Single Quotes are . $time . seconds faster than double quotes. ); } else { $time = $single - $double; echo ( Double Quotes are . $time . seconds faster than single quotes. ); } ? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Here is my test in a PIII 550Mhz 128mb with gentoo: for ($i = 0; $i = ; $i++) { $include = 'db_connect.php'; include('include/'.$include); } 3.623316 seconds -- for ($i = 0; $i = ; $i++) { $include = db_connect.php; include(include/$include); } 3.696468 seconds meatbread. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
xfedex wrote: snip all my stuff Here is my test in a PIII 550Mhz 128mb with gentoo: for ($i = 0; $i = ; $i++) { $include = 'db_connect.php'; include('include/'.$include); } 3.623316 seconds -- for ($i = 0; $i = ; $i++) { $include = db_connect.php; include(include/$include); } 3.696468 seconds meatbread. So basically, I run the test 20 times, include 1000 _different_ files for both single and double quotes in each test, and come up with a mean of about 3 one-thousands of a second in favor of double quotes. Not totally scientific but produces a fairly accurate result. You on the other hand, run a test including the _same_ file 10,000 times (which brings into play error handling if you define a function in that include file) and produce a result with a difference of about 7 one-hundredth of a second. A bit less scientific, but still produces a fairly accurate result. With all that said... 1) The time difference in either test if way too small to make a difference. 2) It's a far cry from one of your earlier posts which read, Welli have a 30k script, with double i get 8 or 9 seconds, with sigle i get 0.05 or 0.08 seconds. The script basically made a lot of querys, its part of a user manager module of a system im writing. 3) Meatbread indeed. -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
Hello Marquez, Wednesday, March 30, 2005, 2:41:15 AM, you wrote: MD Does anyone know how to include a variable page? The variable is a page MD name. Such as inluded_file.html MD Include ('../includes/$include'); MD Does not seem to work. You cannot use variables inside single quotes. Try this: include ../includes/$include; Same goes for anything in PHP, i.e.: $test = apple; $word1 = eat the $test; $word2 = 'eat the $test'; Try this and see the difference the quotes make. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I do not fear computers. I fear the lack of them. - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file
Try it with double quotes instead: include( ../includes/$include ); That way works for me. And I also hope you're cleansing or filtering $include in some way. On Tue, 29 Mar 2005 19:41:15 -0600, Marquez Design [EMAIL PROTECTED] wrote: Does anyone know how to include a variable page? The variable is a page name. Such as inluded_file.html Include ('../includes/$include'); Does not seem to work. Thanks! -- Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file with parameters
On Tuesday 12 November 2002 15:55, Fikret CAN wrote: hello PHP developers, I am going to convert a site that works with frames to the equivalent with includes. I have several template files whic behaves according to query string parameters. I don't want to make big changes, just make it work. ?php include(tmplt1.php?var1=val1var2=val2); ? Try this way: ?php $var1=val1; $var2=val2; include(tmplt1.php); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file with parameters
On Tuesday 12 November 2002 15:55, Fikret CAN wrote: hello PHP developers, I am going to convert a site that works with frames to the equivalent with includes. I have several template files whic behaves according to query string parameters. I don't want to make big changes, just make it work. ?php include(tmplt1.php?var1=val1var2=val2); ? You don't need to pass vars to an include file. Whatever variables are available to the main script at the time of the include() are available to the included file. It's the same as copying that code into your main file at that point. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include file for MySQL insert rows
INCLUDE is not really what you are looking for. INCLUDE is more to read in files that contain PHP code. If I'm understanding correctly, what you want to do is to read each line from your file and put each line into a separate variable. Then, you can create the INSERT statement for each row. It might go something like this: $fp = fopen(testsql,r) ; while ($row = fgets($fp,1024)) { $query = INSERT INTO catalogwinetmp VALUES $row; $result = mysql_query($query); } It looks like there might be something at the end of each line that you need to remove before you construct the query. A comma on the first line and a semicolon on the second line. Janet - Original Message - From: Paul Fowler [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, February 17, 2002 8:17 PM Subject: [PHP] Include file for MySQL insert rows I am very new at this and am having trouble migrating to php and mysql from a different system (WebCatalog). I want to start dumping files to text and let php use them to populate mysql on the fly as I start migrating. snip--- $db = mysql_pconnect(host, user, pass); $query = insert into catalogwinetmp values include(testsql); $result = mysql_query($query); ---end-snip The contents of testsql look like this (19, 38080, 'Senejac', 'Haut-Medoc / Cru Bourgeois', '', 12, 1995, 'Bottle - .75L', 'LN, LE, CI', 135, '/collectors/images/bottles/38080.JPG'), (20, 38780, 'Yquem', 'Sauternes / Premier Cru Superieur', '', 1, 1927, 'Bottle - .75L', 'TS, LP, CI', 465, '/collectors/images/bottles/38780.JPG'); Just with more lines (1-18). But I can not get rid of errors in the $query = insert into catalogwinetmp values include(testsql); No matter what quotes and semi-colons I put in testsql or in this script. If I try to set the contents of the include into a variable as in: $rowsToAdd = include(testsql); all I get is the value 1, I guess this is because it is successful. If I could get a variable to contain the contents of the include I am not sure if I could use it in the script. I am not sure if I am even getting warm or if I am on another planet. 1. Any ideas how I can simply make php get a text file into the mysql database? 2. Is there a way to set a (albeit maybe large) variable with the contents of an include file? Sorry to sound like such a php newbie, but I am. Kind thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file by .htaccess
How can I include any html or php file via .htaccess . I want to include an html file in a site contaning around 1000 pages. I want to add header footer dynamically on these pages . Is there any way to include header footer on these pages using .htaccess file. php_value auto_prepend_file header.html php_value auto_append_file footer.php -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include file using .htaccess
thanks for that , it is working fine. keyur - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Keyur Kalaria [EMAIL PROTECTED] Cc: php [EMAIL PROTECTED] Sent: Saturday, April 21, 2001 9:18 PM Subject: Re: [PHP] include file using .htaccess Make sure AllowOverride includes Options and put these lines in your .htaccess: php_value auto_prepend_file header.html php_value auto_append_file footer.html -Rasmus On Sat, 21 Apr 2001, Keyur Kalaria wrote: Hello, How can I include any html or php file via .htaccess ? I want to include an html file in a site contaning around 1000 pages. I want to add header footer dynamically on these pages . Is there any way to include header footer on these pages using .htaccess file. thanks in advance keyur $$$ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include file using .htaccess
Make sure AllowOverride includes Options and put these lines in your .htaccess: php_value auto_prepend_file header.html php_value auto_append_file footer.html -Rasmus On Sat, 21 Apr 2001, Keyur Kalaria wrote: Hello, How can I include any html or php file via .htaccess ? I want to include an html file in a site contaning around 1000 pages. I want to add header footer dynamically on these pages . Is there any way to include header footer on these pages using .htaccess file. thanks in advance keyur $$$ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] include file using .htaccess
the syntax for it is: php_value auto_prepend_file /full/path/to/the/prepend.inc php_value auto_append_file /full/path/to/the/append.inc or you could also do this: php_value include_path /full/path/to/the/includes php_value auto_prepend_file prepend.inc php_value auto_append_file append.inc this would allow you to include anything else you wish inside prepend.inc as well as having some more files included from pages without any full pathes unless they are not found in 'includes' Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Keyur Kalaria [mailto:[EMAIL PROTECTED]] Sent: Sunday, April 22, 2001 12:51 AM To: php Subject: [PHP] include file using .htaccess Hello, How can I include any html or php file via .htaccess ? I want to include an html file in a site contaning around 1000 pages. I want to add header footer dynamically on these pages . Is there any way to include header footer on these pages using .htaccess file. thanks in advance keyur $$$ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] include file
On Mon, 26 Feb 2001 13:29, JW wrote: I have created a config.php3 to store the connection of the database and some constant variable. Then, I created the other file functions.php3 and inculde config.php3 into this file for function.phps3 should use some variables inside the file config.php3. However, I don't know why all the variable cannot display in the function.php3. would anyone please to tell me what is the reason and how I can solve it? You may need to declare the variables global within the function, or pass them as arguments to the function. -- David Robley| WEBMASTER Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet| http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]