Re: [PHP] Silly question
On 11 April 2011 13:23, Stuart Dallas wrote: > On Monday, 11 April 2011 at 13:17, Curtis Maurand wrote: > Stuart Dallas wrote: >> > On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote: >> > nevermind. There is a function: fgetcsv(); >> > >> > Ewww! >> >> Say what you want, it works. Your solution is way more elegant. regex's are >> not my strong suit. I have to have the regex pocket reference to understand >> that regex that's in there. However, the fgetcsv breaks it up into a few >> chunks and I have to break up the first chunk, but that's space delimited, >> so its not so bad. I'll probably use yours. Thanks for the class. > > I'm not a great regex guru either, I googled that - it's not my class. > > You can use a hammer to knock in a screw, but when screwdrivers are > ubiquitously lying around all over the internet, why would you?! > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ > > >> > >> > http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/ >> > >> > -Stuart >> > >> > -- >> > Stuart Dallas >> > 3ft9 Ltd >> > http://3ft9.com/ >> > >> > >> > > Curtis Maurand wrote: >> > > > >> > > > >> > > > Hello, >> > > > I'm trying to run through an apache log >> > > file in an attempt to >> > > > get all of the user agents. >> > > > >> > > > The question is how do I split the >> > > > string? I can't >> > > seem to find a workable delimiter. Each >> > > > section of the >> > > file is enclosed in quotes and that should be helpful, but >> > > > it >> > > doesn't seem to be. I can't seem to set the delimiter to '" >> > > "' I can't >> > > > seem to find any good >> > > > examples, >> > > either. >> > > > >> > > > I can't split on spaces, because the user >> > > > agents generally have spaces in them. >> > > > >> > > > I was >> > > trying to use >> > > > explode. >> > > print_r(explode('" "', $line); >> > > > >> > > > Any help >> > > > would be appreciated. >> > > > thanks, >> > > > Curtis >> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Certain data sequences (especially like the Apache log file), are well documented and as such, due to their regular format, are sometimes easier to read using a regex than by manually pulling apart using string functions. I use an app called RegexBuddy (it's a windows app) which is really useful for describing a regex string in human readable format. I can recommend http://www.regular-expressions.info, http://www.regexbuddy.com and http://www.regular-expressions.info/cookbook.html I am not affiliated with any of these sites/books, just a happy customer. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question
On Monday, 11 April 2011 at 13:17, Curtis Maurand wrote: Stuart Dallas wrote: > > On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote: > > nevermind. There is a function: fgetcsv(); > > > > Ewww! > > Say what you want, it works. Your solution is way more elegant. regex's are > not my strong suit. I have to have the regex pocket reference to understand > that regex that's in there. However, the fgetcsv breaks it up into a few > chunks and I have to break up the first chunk, but that's space delimited, so > its not so bad. I'll probably use yours. Thanks for the class. I'm not a great regex guru either, I googled that - it's not my class. You can use a hammer to knock in a screw, but when screwdrivers are ubiquitously lying around all over the internet, why would you?! -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ > > > > http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/ > > > > -Stuart > > > > -- > > Stuart Dallas > > 3ft9 Ltd > > http://3ft9.com/ > > > > > > > Curtis Maurand wrote: > > > > > > > > > > > > Hello, > > > > I'm trying to run through an apache log > > > file in an attempt to > > > > get all of the user agents. > > > > > > > > The question is how do I split the > > > > string? I can't > > > seem to find a workable delimiter. Each > > > > section of the > > > file is enclosed in quotes and that should be helpful, but > > > > it > > > doesn't seem to be. I can't seem to set the delimiter to '" > > > "' I can't > > > > seem to find any good > > > > examples, > > > either. > > > > > > > > I can't split on spaces, because the user > > > > agents generally have spaces in them. > > > > > > > > I was > > > trying to use > > > > explode. > > > print_r(explode('" "', $line); > > > > > > > > Any help > > > > would be appreciated. > > > > thanks, > > > > Curtis > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question
Stuart Dallas wrote: > On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote: > nevermind. There is a function: fgetcsv(); > > Ewww! Say what you want, it works. Your solution is way more elegant. regex's are not my strong suit. I have to have the regex pocket reference to understand that regex that's in there. However, the fgetcsv breaks it up into a few chunks and I have to break up the first chunk, but that's space delimited, so its not so bad. I'll probably use yours. Thanks for the class. > > http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/ > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ > > >> Curtis Maurand wrote: >> > >> > >> > Hello, >> > I'm trying to run through an apache log >> file in an attempt to >> > get all of the user agents. >> > >> > The question is how do I split the >> > string? I can't >> seem to find a workable delimiter. Each >> > section of the >> file is enclosed in quotes and that should be helpful, but >> > it >> doesn't seem to be. I can't seem to set the delimiter to '" >> "' I can't >> > seem to find any good >> > examples, >> either. >> > >> > I can't split on spaces, because the user >> > agents generally have spaces in them. >> > >> > I was >> trying to use >> > explode. >> print_r(explode('" "', $line); >> > >> > Any help >> > would be appreciated. >> > thanks, >> > Curtis >> > >
Re: [PHP] Silly question
On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote: nevermind. There is a function: fgetcsv(); Ewww! http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/ -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ > Curtis Maurand wrote: > > > > > > Hello, > > I'm trying to run through an apache log > file in an attempt to > > get all of the user agents. > > > > The question is how do I split the > > string? I can't > seem to find a workable delimiter. Each > > section of the > file is enclosed in quotes and that should be helpful, but > > it > doesn't seem to be. I can't seem to set the delimiter to '" > "' I can't > > seem to find any good > > examples, > either. > > > > I can't split on spaces, because the user > > agents generally have spaces in them. > > > > I was > trying to use > > explode. > print_r(explode('" "', $line); > > > > Any help > > would be appreciated. > > thanks, > > Curtis > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question
nevermind. There is a function: fgetcsv(); Thanks, Curtis Curtis Maurand wrote: > > > Hello, > I'm trying to run through an apache log file in an attempt to > get all of the user agents. > > The question is how do I split the > string? I can't seem to find a workable delimiter. Each > section of the file is enclosed in quotes and that should be helpful, but > it doesn't seem to be. I can't seem to set the delimiter to '" "' I can't > seem to find any good > examples, either. > > I can't split on spaces, because the user > agents generally have spaces in them. > > I was trying to use > explode. > > print_r(explode('" "', $line); > > Any help > would be appreciated. > thanks, > Curtis >
[PHP] Silly question
Hello, I'm trying to run through an apache log file in an attempt to get all of the user agents. The question is how do I split the string? I can't seem to find a workable delimiter. Each section of the file is enclosed in quotes and that should be helpful, but it doesn't seem to be. I can't seem to set the delimiter to '" "' I can't seem to find any good examples, either. I can't split on spaces, because the user agents generally have spaces in them. I was trying to use explode. print_r(explode('" "', $line); Any help would be appreciated. thanks, Curtis
Re: [PHP] Silly question - include vs. eval
On Wed, 2009-03-11 at 19:50 -0500, Shawn McKenzie wrote: > Robert Cummings wrote: > > On Wed, 2009-03-11 at 16:16 -0500, Shawn McKenzie wrote: > >> Shawn McKenzie wrote: > >>> Robert Cummings wrote: > On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote: > > Robert Cummings wrote: > >> On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: > >>> Sándor Tamás (HostWare Kft . ) wrote: > Yes, Rob is right. My original question is about the difference > between > the processing of a file-based site with include() OR eval(). In that > case, if I understood it correctly, the results are the same. > > But! If the included pages contain functions, classes, etc. With > eval(), > can I use them? With include(), I know I should be able to use them. > But > in some mysterious cases I don't have access to a function. If I cut > out > from the included file, and put in on the file which includes that, > just > before (or after) the includ(), I don't have any problem with it. > > The next step, that if I include a file in a function, can I use the > functions wrote in the included file? > As I know, include just makes a copy-paste, so if I use it IN a > function, then all function will be in function scope, am I right? > >>> Yes, if you use an include inside a function, then any functions / non > >>> global vars in the included file will only be available inside the > >>> including function. > >> This is NOT, I repeat, NOT true for functions. Functions are ALWAYS > >> global. > >> > >> Cheers, > >> Rob. > > Yes, I was too hasty. The nested function will only be defined once the > > nesting function has been called. Then it will be available globally. > Actually, you're wrong again. The nested function, AKA function defined > in the included source, will be defined as soon as the source is > included and is available to the function in which the source was > included. In fact it is even available to the code within the included > source that can be run during the include process and before the > function performing the inclusion regains control. > > Cheers, > Rob. > >>> Well I used the word defined, however what I meant was the included > >>> function would only be available globally after the including function > >>> has been called. But yes, it will be available to the including function. > >>> > >> Actually, which would mean that the including function had been called > >> if it was attempting to use any of the vars/functions in the included > >> file :-) > > > > You need to work on your use of verb tenses :) > > > > Cheers, > > Rob. > > What? I didn't know you flamed people whose native language wasn't > English! How can we get a break on this list? > > I speak Texan (sorta), and apologize for my poor English. :-( I wasn't flaming, I was providing insight into why your wording was confusing. If I had been flaming I would have used sarcasm or derogatory phrasing to demean your words. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
Robert Cummings wrote: > On Wed, 2009-03-11 at 16:16 -0500, Shawn McKenzie wrote: >> Shawn McKenzie wrote: >>> Robert Cummings wrote: On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote: > Robert Cummings wrote: >> On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: >>> Sándor Tamás (HostWare Kft . ) wrote: Yes, Rob is right. My original question is about the difference between the processing of a file-based site with include() OR eval(). In that case, if I understood it correctly, the results are the same. But! If the included pages contain functions, classes, etc. With eval(), can I use them? With include(), I know I should be able to use them. But in some mysterious cases I don't have access to a function. If I cut out from the included file, and put in on the file which includes that, just before (or after) the includ(), I don't have any problem with it. The next step, that if I include a file in a function, can I use the functions wrote in the included file? As I know, include just makes a copy-paste, so if I use it IN a function, then all function will be in function scope, am I right? >>> Yes, if you use an include inside a function, then any functions / non >>> global vars in the included file will only be available inside the >>> including function. >> This is NOT, I repeat, NOT true for functions. Functions are ALWAYS >> global. >> >> Cheers, >> Rob. > Yes, I was too hasty. The nested function will only be defined once the > nesting function has been called. Then it will be available globally. Actually, you're wrong again. The nested function, AKA function defined in the included source, will be defined as soon as the source is included and is available to the function in which the source was included. In fact it is even available to the code within the included source that can be run during the include process and before the function performing the inclusion regains control. Cheers, Rob. >>> Well I used the word defined, however what I meant was the included >>> function would only be available globally after the including function >>> has been called. But yes, it will be available to the including function. >>> >> Actually, which would mean that the including function had been called >> if it was attempting to use any of the vars/functions in the included >> file :-) > > You need to work on your use of verb tenses :) > > Cheers, > Rob. What? I didn't know you flamed people whose native language wasn't English! How can we get a break on this list? I speak Texan (sorta), and apologize for my poor English. :-( -- 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] Silly question - include vs. eval
On Wed, 2009-03-11 at 16:16 -0500, Shawn McKenzie wrote: > Shawn McKenzie wrote: > > Robert Cummings wrote: > >> On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote: > >>> Robert Cummings wrote: > On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: > > Sándor Tamás (HostWare Kft . ) wrote: > >> Yes, Rob is right. My original question is about the difference between > >> the processing of a file-based site with include() OR eval(). In that > >> case, if I understood it correctly, the results are the same. > >> > >> But! If the included pages contain functions, classes, etc. With > >> eval(), > >> can I use them? With include(), I know I should be able to use them. > >> But > >> in some mysterious cases I don't have access to a function. If I cut > >> out > >> from the included file, and put in on the file which includes that, > >> just > >> before (or after) the includ(), I don't have any problem with it. > >> > >> The next step, that if I include a file in a function, can I use the > >> functions wrote in the included file? > >> As I know, include just makes a copy-paste, so if I use it IN a > >> function, then all function will be in function scope, am I right? > > Yes, if you use an include inside a function, then any functions / non > > global vars in the included file will only be available inside the > > including function. > This is NOT, I repeat, NOT true for functions. Functions are ALWAYS > global. > > Cheers, > Rob. > >>> Yes, I was too hasty. The nested function will only be defined once the > >>> nesting function has been called. Then it will be available globally. > >> > >> Actually, you're wrong again. The nested function, AKA function defined > >> in the included source, will be defined as soon as the source is > >> included and is available to the function in which the source was > >> included. In fact it is even available to the code within the included > >> source that can be run during the include process and before the > >> function performing the inclusion regains control. > >> > >> Cheers, > >> Rob. > > > > Well I used the word defined, however what I meant was the included > > function would only be available globally after the including function > > has been called. But yes, it will be available to the including function. > > > > Actually, which would mean that the including function had been called > if it was attempting to use any of the vars/functions in the included > file :-) You need to work on your use of verb tenses :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
Shawn McKenzie wrote: > Robert Cummings wrote: >> On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote: >>> Robert Cummings wrote: On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: > Sándor Tamás (HostWare Kft . ) wrote: >> Yes, Rob is right. My original question is about the difference between >> the processing of a file-based site with include() OR eval(). In that >> case, if I understood it correctly, the results are the same. >> >> But! If the included pages contain functions, classes, etc. With eval(), >> can I use them? With include(), I know I should be able to use them. But >> in some mysterious cases I don't have access to a function. If I cut out >> from the included file, and put in on the file which includes that, just >> before (or after) the includ(), I don't have any problem with it. >> >> The next step, that if I include a file in a function, can I use the >> functions wrote in the included file? >> As I know, include just makes a copy-paste, so if I use it IN a >> function, then all function will be in function scope, am I right? > Yes, if you use an include inside a function, then any functions / non > global vars in the included file will only be available inside the > including function. This is NOT, I repeat, NOT true for functions. Functions are ALWAYS global. Cheers, Rob. >>> Yes, I was too hasty. The nested function will only be defined once the >>> nesting function has been called. Then it will be available globally. >> Actually, you're wrong again. The nested function, AKA function defined >> in the included source, will be defined as soon as the source is >> included and is available to the function in which the source was >> included. In fact it is even available to the code within the included >> source that can be run during the include process and before the >> function performing the inclusion regains control. >> >> Cheers, >> Rob. > > Well I used the word defined, however what I meant was the included > function would only be available globally after the including function > has been called. But yes, it will be available to the including function. > Actually, which would mean that the including function had been called if it was attempting to use any of the vars/functions in the included file :-) -- 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] Silly question - include vs. eval
Robert Cummings wrote: > On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote: >> Robert Cummings wrote: >>> On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: Sándor Tamás (HostWare Kft . ) wrote: > Yes, Rob is right. My original question is about the difference between > the processing of a file-based site with include() OR eval(). In that > case, if I understood it correctly, the results are the same. > > But! If the included pages contain functions, classes, etc. With eval(), > can I use them? With include(), I know I should be able to use them. But > in some mysterious cases I don't have access to a function. If I cut out > from the included file, and put in on the file which includes that, just > before (or after) the includ(), I don't have any problem with it. > > The next step, that if I include a file in a function, can I use the > functions wrote in the included file? > As I know, include just makes a copy-paste, so if I use it IN a > function, then all function will be in function scope, am I right? Yes, if you use an include inside a function, then any functions / non global vars in the included file will only be available inside the including function. >>> This is NOT, I repeat, NOT true for functions. Functions are ALWAYS >>> global. >>> >>> Cheers, >>> Rob. >> Yes, I was too hasty. The nested function will only be defined once the >> nesting function has been called. Then it will be available globally. > > Actually, you're wrong again. The nested function, AKA function defined > in the included source, will be defined as soon as the source is > included and is available to the function in which the source was > included. In fact it is even available to the code within the included > source that can be run during the include process and before the > function performing the inclusion regains control. > > Cheers, > Rob. Well I used the word defined, however what I meant was the included function would only be available globally after the including function has been called. But yes, it will be available to the including function. -- 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] Silly question - include vs. eval
On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote: > Robert Cummings wrote: > > On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: > >> Sándor Tamás (HostWare Kft . ) wrote: > >>> Yes, Rob is right. My original question is about the difference between > >>> the processing of a file-based site with include() OR eval(). In that > >>> case, if I understood it correctly, the results are the same. > >>> > >>> But! If the included pages contain functions, classes, etc. With eval(), > >>> can I use them? With include(), I know I should be able to use them. But > >>> in some mysterious cases I don't have access to a function. If I cut out > >>> from the included file, and put in on the file which includes that, just > >>> before (or after) the includ(), I don't have any problem with it. > >>> > >>> The next step, that if I include a file in a function, can I use the > >>> functions wrote in the included file? > >>> As I know, include just makes a copy-paste, so if I use it IN a > >>> function, then all function will be in function scope, am I right? > >> Yes, if you use an include inside a function, then any functions / non > >> global vars in the included file will only be available inside the > >> including function. > > > > This is NOT, I repeat, NOT true for functions. Functions are ALWAYS > > global. > > > > Cheers, > > Rob. > > Yes, I was too hasty. The nested function will only be defined once the > nesting function has been called. Then it will be available globally. Actually, you're wrong again. The nested function, AKA function defined in the included source, will be defined as soon as the source is included and is available to the function in which the source was included. In fact it is even available to the code within the included source that can be run during the include process and before the function performing the inclusion regains control. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
Robert Cummings wrote: > On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: >> Sándor Tamás (HostWare Kft . ) wrote: >>> Yes, Rob is right. My original question is about the difference between >>> the processing of a file-based site with include() OR eval(). In that >>> case, if I understood it correctly, the results are the same. >>> >>> But! If the included pages contain functions, classes, etc. With eval(), >>> can I use them? With include(), I know I should be able to use them. But >>> in some mysterious cases I don't have access to a function. If I cut out >>> from the included file, and put in on the file which includes that, just >>> before (or after) the includ(), I don't have any problem with it. >>> >>> The next step, that if I include a file in a function, can I use the >>> functions wrote in the included file? >>> As I know, include just makes a copy-paste, so if I use it IN a >>> function, then all function will be in function scope, am I right? >> Yes, if you use an include inside a function, then any functions / non >> global vars in the included file will only be available inside the >> including function. > > This is NOT, I repeat, NOT true for functions. Functions are ALWAYS > global. > > Cheers, > Rob. Yes, I was too hasty. The nested function will only be defined once the nesting function has been called. Then it will be available globally. -- 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] Silly question - include vs. eval
On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: > Sándor Tamás (HostWare Kft . ) wrote: > > Yes, Rob is right. My original question is about the difference between > > the processing of a file-based site with include() OR eval(). In that > > case, if I understood it correctly, the results are the same. > > > > But! If the included pages contain functions, classes, etc. With eval(), > > can I use them? With include(), I know I should be able to use them. But > > in some mysterious cases I don't have access to a function. If I cut out > > from the included file, and put in on the file which includes that, just > > before (or after) the includ(), I don't have any problem with it. > > > > The next step, that if I include a file in a function, can I use the > > functions wrote in the included file? > > As I know, include just makes a copy-paste, so if I use it IN a > > function, then all function will be in function scope, am I right? > > Yes, if you use an include inside a function, then any functions / non > global vars in the included file will only be available inside the > including function. This is NOT, I repeat, NOT true for functions. Functions are ALWAYS global. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
On Wed, Mar 11, 2009 at 10:19 AM, Shawn McKenzie wrote: > Sándor Tamás (HostWare Kft . ) wrote: > > Yes, Rob is right. My original question is about the difference between > > the processing of a file-based site with include() OR eval(). In that > > case, if I understood it correctly, the results are the same. > > > > But! If the included pages contain functions, classes, etc. With eval(), > > can I use them? With include(), I know I should be able to use them. But > > in some mysterious cases I don't have access to a function. If I cut out > > from the included file, and put in on the file which includes that, just > > before (or after) the includ(), I don't have any problem with it. > > > > The next step, that if I include a file in a function, can I use the > > functions wrote in the included file? > > As I know, include just makes a copy-paste, so if I use it IN a > > function, then all function will be in function scope, am I right? > > Yes, if you use an include inside a function, then any functions / non > global vars in the included file will only be available inside the > including function. > > > -- > Thanks! > -Shawn > http://www.spidean.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Evals make my head hurt. I still opt for evil() being a native alias of eval().
Re: [PHP] Silly question - include vs. eval
Sándor Tamás (HostWare Kft . ) wrote: > Yes, Rob is right. My original question is about the difference between > the processing of a file-based site with include() OR eval(). In that > case, if I understood it correctly, the results are the same. > > But! If the included pages contain functions, classes, etc. With eval(), > can I use them? With include(), I know I should be able to use them. But > in some mysterious cases I don't have access to a function. If I cut out > from the included file, and put in on the file which includes that, just > before (or after) the includ(), I don't have any problem with it. > > The next step, that if I include a file in a function, can I use the > functions wrote in the included file? > As I know, include just makes a copy-paste, so if I use it IN a > function, then all function will be in function scope, am I right? Yes, if you use an include inside a function, then any functions / non global vars in the included file will only be available inside the including function. -- 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] Silly question - include vs. eval
On Wed, 2009-03-11 at 14:03 +0100, Sándor Tamás (HostWare Kft.) wrote: > Yes, Rob is right. My original question is about the difference between the > processing of a file-based site with include() OR eval(). In that case, if I > understood it correctly, the results are the same. > > But! If the included pages contain functions, classes, etc. With eval(), can > I use them? With include(), I know I should be able to use them. But in some > mysterious cases I don't have access to a function. If I cut out from the > included file, and put in on the file which includes that, just before (or > after) the includ(), I don't have any problem with it. > > The next step, that if I include a file in a function, can I use the > functions wrote in the included file? > As I know, include just makes a copy-paste, so if I use it IN a function, > then all function will be in function scope, am I right? You should be able to use any functions you declare in the external source from within the including context... but only after the include. This is true whether you include or eval the content. It's interesting your mention a mysterious case... I remember a couple of years ago an include issue where the functions were not available as they should have been... I resolved it by doing an eval on the contents of the file instead. I think it was probably some bug in PHP and it eventually resolved itself and it had worked before an upgrade. I never bothered with a bug report though because I couldn't distill it down to a simple use case. What version are you using? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
Yes, Rob is right. My original question is about the difference between the processing of a file-based site with include() OR eval(). In that case, if I understood it correctly, the results are the same. But! If the included pages contain functions, classes, etc. With eval(), can I use them? With include(), I know I should be able to use them. But in some mysterious cases I don't have access to a function. If I cut out from the included file, and put in on the file which includes that, just before (or after) the includ(), I don't have any problem with it. The next step, that if I include a file in a function, can I use the functions wrote in the included file? As I know, include just makes a copy-paste, so if I use it IN a function, then all function will be in function scope, am I right? SanTa - Original Message - From: "Robert Cummings" To: "Virgilio Quilario" Cc: "Sándor Tamás (HostWare Kft.)" ; Sent: Wednesday, March 11, 2009 1:55 PM Subject: Re: [PHP] Silly question - include vs. eval On Wed, 2009-03-11 at 20:49 +0800, Virgilio Quilario wrote: >> Hi, >> >> I wondering what is the difference between include(), and eval(' >> ?>'.file_get_content().' >> >> If there is something I should be aware, please, let me know. > > Use include since it allows a cache like eAccelerator or APC to work. > Eval never gets cached. Also, include let's the engine do the opening, > reading, closing of the file while also parsing and running the > contents > in one fell function call (yes I know it's not a function). What you > have above, using eval, is a bastardization of cleanliness and > succinctness of code. > > Cheers, > Rob. hi, eval is useful when your php code is stored in database. read here http://www.php.net/manual/en/function.eval.php for details. I'm going to go out on a limb here... it would probably make your application faster if you used a file based cache for content to be eval'd and then included the cached file instead. Then whatever accelerator is in play can do it's thing on the code. But the poster didn't ask about content in general, he asked about the difference between include and eval'ing content acquired from a file. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
On Wed, 2009-03-11 at 20:49 +0800, Virgilio Quilario wrote: > >> Hi, > >> > >> I wondering what is the difference between include(), and eval(' > >> ?>'.file_get_content().' >> > >> If there is something I should be aware, please, let me know. > > > > Use include since it allows a cache like eAccelerator or APC to work. > > Eval never gets cached. Also, include let's the engine do the opening, > > reading, closing of the file while also parsing and running the contents > > in one fell function call (yes I know it's not a function). What you > > have above, using eval, is a bastardization of cleanliness and > > succinctness of code. > > > > Cheers, > > Rob. > > hi, > > eval is useful when your php code is stored in database. > read here http://www.php.net/manual/en/function.eval.php for details. I'm going to go out on a limb here... it would probably make your application faster if you used a file based cache for content to be eval'd and then included the cached file instead. Then whatever accelerator is in play can do it's thing on the code. But the poster didn't ask about content in general, he asked about the difference between include and eval'ing content acquired from a file. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
>> Hi, >> >> I wondering what is the difference between include(), and eval(' >> ?>'.file_get_content().' > >> If there is something I should be aware, please, let me know. > > Use include since it allows a cache like eAccelerator or APC to work. > Eval never gets cached. Also, include let's the engine do the opening, > reading, closing of the file while also parsing and running the contents > in one fell function call (yes I know it's not a function). What you > have above, using eval, is a bastardization of cleanliness and > succinctness of code. > > Cheers, > Rob. hi, eval is useful when your php code is stored in database. read here http://www.php.net/manual/en/function.eval.php for details. Virgil http://www.jampmark.com Free tips, tutorials, innovative tools and techniques for building and improving web sites -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
On Wed, 2009-03-11 at 08:33 -0400, Robert Cummings wrote: > On Wed, 2009-03-11 at 13:07 +0100, Sándor Tamás (HostWare Kft.) wrote: > > Hi, > > > > I wondering what is the difference between include(), and eval(' > > ?>'.file_get_content().' > > > If there is something I should be aware, please, let me know. > > Use include since it allows a cache like eAccelerator or APC to work. > Eval never gets cached. Also, include let's the engine do the opening, Before someone mentions it... yes I know there shouldn't be an apostrophe in the above "let's"... sometimes my fingers make executive decisions all by themselves :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly question - include vs. eval
On Wed, 2009-03-11 at 13:07 +0100, Sándor Tamás (HostWare Kft.) wrote: > Hi, > > I wondering what is the difference between include(), and eval(' > ?>'.file_get_content().' > If there is something I should be aware, please, let me know. Use include since it allows a cache like eAccelerator or APC to work. Eval never gets cached. Also, include let's the engine do the opening, reading, closing of the file while also parsing and running the contents in one fell function call (yes I know it's not a function). What you have above, using eval, is a bastardization of cleanliness and succinctness of code. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Silly question - include vs. eval
Hi, I wondering what is the difference between include(), and eval(' ?>'.file_get_content().'
Re: [PHP] silly question - setting .php as default extension (Apache)
On Tuesday 09 November 2004 16:04, Brian A. Anderson wrote: > Uuuuh... Where do I set the default server extension type to .php > in the apache config? Right now the page will execute on my server, > but if there is an index.php the server won't automatically open > it, but instead browses the directory. > > Thanks in advance, > > -Brian Your probably looking for the DirectoryIndex directive. Apache 1.3.x http://httpd.apache.org/docs/mod/mod_dir.html#directoryindex Apache 2.0.x http://httpd.apache.org/docs-2.0/mod/mod_dir.html#directoryindex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] silly question - setting .php as default extension (Apache)
Coolbeans guys! :) Thanks, -Brian - Original Message - From: "Marek Kilimajer" <[EMAIL PROTECTED]> To: "Brian A. Anderson" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, November 09, 2004 4:07 PM Subject: Re: [PHP] silly question - setting .php as default extension (Apache) > Brian A. Anderson wrote: > > Uuuuh... Where do I set the default server extension type to .php in the > > apache config? Right now the page will execute on my server, but if there is > > an index.php the server won't automatically open it, but instead browses the > > directory. > > DirectoryIndex index.html index.php ... > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] silly question - setting .php as default extension (Apache)
> > Uuuuh... Where do I set the default server extension type to .php in the > apache config? Right now the page will execute on my server, but > if there is > an index.php the server won't automatically open it, but instead > browses the > directory. > > Thanks in advance, > > -Brian Look for DirectoryIndex in httpd.conf and add index.php OR On my Apache2/Linux installation I had to uncomment a line in : /etc/httpd/conf.d/php.conf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] silly question - setting .php as default extension (Apache)
Brian A. Anderson wrote: Uuuuh... Where do I set the default server extension type to .php in the apache config? Right now the page will execute on my server, but if there is an index.php the server won't automatically open it, but instead browses the directory. DirectoryIndex index.html index.php ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] silly question - setting .php as default extension (Apache)
Uuuuh... Where do I set the default server extension type to .php in the apache config? Right now the page will execute on my server, but if there is an index.php the server won't automatically open it, but instead browses the directory. Thanks in advance, -Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] silly question: an IDE for php?
Burhan Khalid wrote: Is there an alternative free (free as in 'beer') IDE rather than Zend that I can use to track variables, analize code and so like? I heard of bluefish, is it widely used? PHPEdit would be my recommendation. Although if you are serious about PHP, you should consider investing in Zend. It should be noted that PHPEdit is no longer 'free' and while I still run an older version, it still has a little catching up to do. While PHPEclipse has a little way to go, the Eclipse framework is working well for me, handling everything else like Javascript, style sheets, and PHP auto complete is working fine. Yes Eclipse is a bit of a pig to set up, but on the other hand, once there, it has a lot of power. Just add one of the SQL packages, and manage databases, and XML fits in nicely as well. Just ignore all the Java stuff and you are OK ;) -- Lester Caine - L.S.Caine Electronic Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] silly question: an IDE for php?
Zhang Weiwu wrote: Not to start flame. I have been writing php using just vim for some time, it is a waste of time to put 'echo' statement everywhere to track variable values. I wonder what do the experienced users on php.net use for php development? Do you use IDE? Do you use Zend? Is there an alternative free (free as in 'beer') IDE rather than Zend that I can use to track variables, analize code and so like? I heard of bluefish, is it widely used? PHPEdit would be my recommendation. Although if you are serious about PHP, you should consider investing in Zend. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] silly question: an IDE for php?
Not to start flame. I have been writing php using just vim for some time, it is a waste of time to put 'echo' statement everywhere to track variable values. I wonder what do the experienced users on php.net use for php development? Do you use IDE? Do you use Zend? Is there an alternative free (free as in 'beer') IDE rather than Zend that I can use to track variables, analize code and so like? I heard of bluefish, is it widely used? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] silly question about zend
On Monday 27 October 2003 04:08, Manisha Sathe wrote: > I wanted some sort of IDE for PHP, so decided to use Zend (which i believe > quite popular). > > I installed it on my redhat linux 8.0- both client and server components. > Instructions was smooth and gave me success msg, but now I do not know how > to open the IDE... > > so stupid question.. but still want to know .. how to open Zend so that can > write PHP ?... > > regards > manisha It depends on where you told it to install the links. I believe the default if your home directory. (The one who installed it.) Look in their directory for a directory called ZDE* there should be a symbolic link in one of them unless you changed it. (Note: The names are ridiculously long) -- Ryan Thompson [EMAIL PROTECTED] http://osgw.sourceforge.net == "A computer scientist is someone who fixes things that aren't broken" --Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] silly question about zend
I wanted some sort of IDE for PHP, so decided to use Zend (which i believe quite popular). I installed it on my redhat linux 8.0- both client and server components. Instructions was smooth and gave me success msg, but now I do not know how to open the IDE... so stupid question.. but still want to know .. how to open Zend so that can write PHP ?... regards manisha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] silly question
I assume that you have or some variation thereof. In that case, just set $field1 = "" after you save the record, or remove the value="" statement altogether. Mike Rodrigo Peres wrote: >Hi list, > >I have PHP code to insert the result of a form into mysql. When I nedd to >made an update, I pass an "id" in the url and use it to make the update >query. The problem is after I click in the update button (input submit) my >page refresh and came back in the same state, to see the changes I need to >type in the url again with the parameter?? why?? There's a way to avoid this >and get a new blank form page after the update? > >ps: I've stored the "id" in a input type hidden, so I could click the button >and still have the id > >Thank's in advance > >Rodrigo Peres > -- 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] silly question
Take care to be sure that you make the update, before the rest of the page loads, things happen in order, so it's almost like creating your page backwards (I just had that problem). I can elaborate if you like. (C: [EMAIL PROTECTED] wrote: >Hi list, > >I have PHP code to insert the result of a form into mysql. When I nedd to >made an update, I pass an "id" in the url and use it to make the update >query. The problem is after I click in the update button (input submit) my >page refresh and came back in the same state, to see the changes I need to >type in the url again with the parameter?? why?? There's a way to avoid this >and get a new blank form page after the update? > >ps: I've stored the "id" in a input type hidden, so I could click the button >and still have the id > >Thank's in advance > >Rodrigo Peres > -- 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] silly question cont...
Sorry all, just to add a little info, the inpu hidden i've mentioned in the other message is made if exist the id in the url!! it isn't all the time there :-) thks again Rodrigo -- 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] silly question
try adding the "nocache" header() calls to the page to force the broswer to refresh. See how that goes Martin T -Original Message- From: Rodrigo Peres [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 9:43 AM To: PHP Subject: [PHP] silly question Hi list, I have PHP code to insert the result of a form into mysql. When I nedd to made an update, I pass an "id" in the url and use it to make the update query. The problem is after I click in the update button (input submit) my page refresh and came back in the same state, to see the changes I need to type in the url again with the parameter?? why?? There's a way to avoid this and get a new blank form page after the update? ps: I've stored the "id" in a input type hidden, so I could click the button and still have the id Thank's in advance Rodrigo Peres -- -- 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] silly question
Hi list, I have PHP code to insert the result of a form into mysql. When I nedd to made an update, I pass an "id" in the url and use it to make the update query. The problem is after I click in the update button (input submit) my page refresh and came back in the same state, to see the changes I need to type in the url again with the parameter?? why?? There's a way to avoid this and get a new blank form page after the update? ps: I've stored the "id" in a input type hidden, so I could click the button and still have the id Thank's in advance Rodrigo Peres -- -- 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]