[PHP] Re: Functions vs html outpuit
On Fri, 01 Sep 2006 16:44:19 +0200, M. Sokolewicz wrote: > Dave Goodchild wrote: >> Hi all, this may seem like a silly question, but I am creating a library of >> html form element generation function, for example a textarea fucntion that >> takes rows and cols as parameters, a function that generates a day, month >> and year select box, etc. My question is - is it significantly to switch >> off >> the parser and emit raw html than calling a function? If it is faster to >> just allow the server to send the html I will not bother. >> > > I'm not quite sure I understand your question. Are you asking if it's > faster to parse and process a php script vs. a page of raw HTML? > > In that case, OF COURSE SERVING A RAW HTML FILE IS FASTER!!! > Does the server have to do *anything* with the contents of the HMTL file? no > Does the server have to do *anything* with the contents of the PHP file? > yes! of course! it needs to parse and process it BEFORE it can actually > server the RESULT of that script. > > So, if possible, stick to raw HTML files. > - tul That said, if you feel that it saves you a lot of development time (like me) to use such functions, and you're writing a basic app that will not likely attract lots of hits, then go for it. I use a viewForm() function, that takes an array as a argument describing the required form, for all of my projects. Surely it's faster for the server if you just write the HTML, but this is much easier for me to create, edit and re-use in other projects... Just my 2 cts. Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Organizing php functions
On Fri, 01 Sep 2006 21:35:32 -0600, The Doctor wrote: > The question comes up because: > > Sort file in the path interfere with one another > > which leads to > > web page malfunction. > > Question: should all php programmes such as drupal be placed > under /usr/local/lib ? I'm not getting the 'sort file' problem, but you can put PHP apps wherever; as long as you tell Apache/your webserver where to find it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Crazy behavior...
Hi, This is really odd. I use this code to retrive value from a database table. When the field is empty, it cracks the HTML code some how, the PHP script seam to not break. function getInfo() { $html = ""; $html.= "Name".$this->getName().""; $html.= "Description".$this->getDesc().""; $html.= "Priority".$this->getPriorityText().""; $html.= ""; return $html; } The function getDesc is like this (I have made it overly complicated because I am trying to fix the problem): function getDesc() { $Query = sprintf("SELECT todotext FROM teamtodo WHERE id=%d LIMIT 1", $this->getID()); $Result = mysql_query($Query); if(mysql_num_rows($Result)>0) { if($Roww = mysql_fetch_array($Result)) { if($Roww['todotext']!='') return $Roww['todotext']; else return ''; } else return ''; } else return ''; } When the database field is not empty it works fine, but as soon as the field todotext is empty the $html seam to break, but the value of $html until the $this->getDesc() is still being returned by the function (can see half of the table). Is this a bug, or am I just stupid? If I just insert some blank spaces it works, hrm. /Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Functions vs html outpuit
Thanks, that was what I needed to hear. Cheers. On 03/09/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: On Fri, 01 Sep 2006 16:44:19 +0200, M. Sokolewicz wrote: > Dave Goodchild wrote: >> Hi all, this may seem like a silly question, but I am creating a library of >> html form element generation function, for example a textarea fucntion that >> takes rows and cols as parameters, a function that generates a day, month >> and year select box, etc. My question is - is it significantly to switch >> off >> the parser and emit raw html than calling a function? If it is faster to >> just allow the server to send the html I will not bother. >> > > I'm not quite sure I understand your question. Are you asking if it's > faster to parse and process a php script vs. a page of raw HTML? > > In that case, OF COURSE SERVING A RAW HTML FILE IS FASTER!!! > Does the server have to do *anything* with the contents of the HMTL file? no > Does the server have to do *anything* with the contents of the PHP file? > yes! of course! it needs to parse and process it BEFORE it can actually > server the RESULT of that script. > > So, if possible, stick to raw HTML files. > - tul That said, if you feel that it saves you a lot of development time (like me) to use such functions, and you're writing a basic app that will not likely attract lots of hits, then go for it. I use a viewForm() function, that takes an array as a argument describing the required form, for all of my projects. Surely it's faster for the server if you just write the HTML, but this is much easier for me to create, edit and re-use in other projects... Just my 2 cts. Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
RE: [PHP] Crazy behavior...
Just figured out that it seams to happen when the request is done via AJAX. But it does not make any sense to me that there should be any difference. /Peter -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: Sunday, September 03, 2006 1:53 PM To: php-general@lists.php.net Subject: [PHP] Crazy behavior... Hi, This is really odd. I use this code to retrive value from a database table. When the field is empty, it cracks the HTML code some how, the PHP script seam to not break. function getInfo() { $html = ""; $html.= "Name".$this->getName().""; $html.= "Description".$this->getDesc().""; $html.= "Priority".$this->getPriorityText().""; $html.= ""; return $html; } The function getDesc is like this (I have made it overly complicated because I am trying to fix the problem): function getDesc() { $Query = sprintf("SELECT todotext FROM teamtodo WHERE id=%d LIMIT 1", $this->getID()); $Result = mysql_query($Query); if(mysql_num_rows($Result)>0) { if($Roww = mysql_fetch_array($Result)) { if($Roww['todotext']!='') return $Roww['todotext']; else return ''; } else return ''; } else return ''; } When the database field is not empty it works fine, but as soon as the field todotext is empty the $html seam to break, but the value of $html until the $this->getDesc() is still being returned by the function (can see half of the table). Is this a bug, or am I just stupid? If I just insert some blank spaces it works, hrm. /Peter -- 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] Re: Functions vs html outpuit
Dave Goodchild wrote: Thanks, that was what I needed to hear. Cheers. On 03/09/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: On Fri, 01 Sep 2006 16:44:19 +0200, M. Sokolewicz wrote: > Dave Goodchild wrote: >> Hi all, this may seem like a silly question, but I am creating a library of >> html form element generation function, for example a textarea fucntion that >> takes rows and cols as parameters, a function that generates a day, month >> and year select box, etc. My question is - is it significantly to switch >> off >> the parser and emit raw html than calling a function? If it is faster to >> just allow the server to send the html I will not bother. >> > > I'm not quite sure I understand your question. Are you asking if it's > faster to parse and process a php script vs. a page of raw HTML? > > In that case, OF COURSE SERVING A RAW HTML FILE IS FASTER!!! > Does the server have to do *anything* with the contents of the HMTL file? no > Does the server have to do *anything* with the contents of the PHP file? > yes! of course! it needs to parse and process it BEFORE it can actually > server the RESULT of that script. > > So, if possible, stick to raw HTML files. > - tul That said, if you feel that it saves you a lot of development time (like me) to use such functions, and you're writing a basic app that will not likely attract lots of hits, then go for it. I use a viewForm() function, that takes an array as a argument describing the required form, for all of my projects. Surely it's faster for the server if you just write the HTML, but this is much easier for me to create, edit and re-use in other projects... Just my 2 cts. Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It does seem to me that a lot a pages end up with PHP in them to do stuff that could be put in raw HTML. The reason being to make the pages easier to manage and port. I would go for the optimize late philosophy. Once you have a site running, load testing it with - eg - JMeter. If a PHP page is taking a lot of the time and it could easily be converted to static HTML, do it at that point. If you code raw HTML everywhere, then you might find that you have spent a day messing with a page that only gets hit once a day :-( Best wishes AJ -- www.deployview.com www.nerds-central.com www.project-network.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Crazy behavior...
Peter Lauri wrote: Just figured out that it seams to happen when the request is done via AJAX. But it does not make any sense to me that there should be any difference. /Peter -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: Sunday, September 03, 2006 1:53 PM To: php-general@lists.php.net Subject: [PHP] Crazy behavior... Hi, This is really odd. I use this code to retrive value from a database table. When the field is empty, it cracks the HTML code some how, the PHP script seam to not break. function getInfo() { $html = ""; $html.= "Name".$this->getName().""; $html.= "Description".$this->getDesc().""; $html.= "Priority".$this->getPriorityText().""; $html.= ""; return $html; } The function getDesc is like this (I have made it overly complicated because I am trying to fix the problem): function getDesc() { $Query = sprintf("SELECT todotext FROM teamtodo WHERE id=%d LIMIT 1", $this->getID()); $Result = mysql_query($Query); if(mysql_num_rows($Result)>0) { if($Roww = mysql_fetch_array($Result)) { if($Roww['todotext']!='') return $Roww['todotext']; else return ''; } else return ''; } else return ''; } When the database field is not empty it works fine, but as soon as the field todotext is empty the $html seam to break, but the value of $html until the $this->getDesc() is still being returned by the function (can see half of the table). Is this a bug, or am I just stupid? If I just insert some blank spaces it works, hrm. /Peter Can you send an example of the broken HTML? What are the symptoms of the html being broken. Finally, in what way are you using AJAX. This looks like html output - so is it really AJAH? My first guess is that something about the context at the browser end makes - an empty table element - cause trouble. Cheers AJ -- www.deployview.com www.nerds-central.com www.project-network.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Crazy behavior...
[snip] Can you send an example of the broken HTML? What are the symptoms of the html being broken. Finally, in what way are you using AJAX. This looks like html output - so is it really AJAH? My first guess is that something about the context at the browser end makes - an empty table element - cause trouble. Cheers AJ [/snip] This is really odd. I wrote the $html variable that I send back to the browser via AJAX, and that code is like this when I pushed it into a temporary database table: Close Nameasdf Description Assigned to Created byPeter Lauri(Farang) Due date Start date PriorityNormal Creation dateSun, 03 Sep 2006 23:09:44 +0700 However, if I just use that output all is shown until the empty tag. Then I tried to check what is actually captured by the browser, and it was showing only until the and then nothing more. So this should maybe be posted to the JavaScript list :) I have temporary solved by NOT allowing empty strings into those fields, but the description should be able to be empty :) /Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Crazy behavior...
Peter, When it arrives at the browser, via ajax, I am guessing that you then put it into the page view .innerHTML or some other method. I suspect your problem revolves around asking the browser to do stuff it should not really have to do. There are two issues I would like to highlight with the html. 1) You are mixing TH and TD on the same row. You should be using styles to set the different presentations of the elements. 2) You have placed a paragraph section between the table tag and the first tr tag. This is wrong. I suspect that the browser is managing to cope with this markup when presented as a static page but is unable to figure out how to update an existing page with it. If you fix the html to be standards compliant then the chances are all will be well. If it is not - by all means get back to me :-) Best wishes AJ Alexander J Turner Ph.D. www.deployview.com www.nerds-central.blogspot.com www.project-network.com -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: 03 September 2006 17:20 To: Alex Turner; php-general@lists.php.net Subject: RE: [PHP] Crazy behavior... [snip] Can you send an example of the broken HTML? What are the symptoms of the html being broken. Finally, in what way are you using AJAX. This looks like html output - so is it really AJAH? My first guess is that something about the context at the browser end makes - an empty table element - cause trouble. Cheers AJ [/snip] This is really odd. I wrote the $html variable that I send back to the browser via AJAX, and that code is like this when I pushed it into a temporary database table: Close Nameasdf Description Assigned to Created byPeter Lauri(Farang) Due date Start date PriorityNormal Creation dateSun, 03 Sep 2006 23:09:44 +0700 However, if I just use that output all is shown until the empty tag. Then I tried to check what is actually captured by the browser, and it was showing only until the and then nothing more. So this should maybe be posted to the JavaScript list :) I have temporary solved by NOT allowing empty strings into those fields, but the description should be able to be empty :) /Peter -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Functions vs html outpuit
On Sunday 03 September 2006 09:00, Alex Turner wrote: > I would go for the optimize late philosophy. Once you have a site > running, load testing it with - eg - JMeter. If a PHP page is taking a > lot of the time and it could easily be converted to static HTML, do it > at that point. If you code raw HTML everywhere, then you might find > that you have spent a day messing with a page that only gets hit once a > day :-( > > Best wishes > > AJ "Pre-mature optimization is the root of all evil." Unless you're building something you know will be very time sensitive, or a part of the code that you know will run every single page view, optimize first for maintainability/modifiability. That is, write code that is easy to understand and easy to tweak. That means opting for generalized, flexible code when possible. Sometimes that will mean writing all your HTML via print, sometimes it will mean static HTML files (although it almost never does for me), sometimes that will mean including a mostly-HTML file with PHP print statements into a mostly-PHP function to use as a poor man's template. In my experience, the time it takes to connect to your SQL database in the first place will be an order of magnitude larger than whatever it is you're doing anyway. :-) -- 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] Crazy behavior...
Just thought one thing. I did do a alert() on the http.responseText, and that breaks in on the too, so the response that is sent back probably just ends there... weird... /Peter -Original Message- From: Alex Turner [mailto:[EMAIL PROTECTED] Sent: Sunday, September 03, 2006 11:31 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: RE: [PHP] Crazy behavior... Peter, When it arrives at the browser, via ajax, I am guessing that you then put it into the page view .innerHTML or some other method. I suspect your problem revolves around asking the browser to do stuff it should not really have to do. There are two issues I would like to highlight with the html. 1) You are mixing TH and TD on the same row. You should be using styles to set the different presentations of the elements. 2) You have placed a paragraph section between the table tag and the first tr tag. This is wrong. I suspect that the browser is managing to cope with this markup when presented as a static page but is unable to figure out how to update an existing page with it. If you fix the html to be standards compliant then the chances are all will be well. If it is not - by all means get back to me :-) Best wishes AJ Alexander J Turner Ph.D. www.deployview.com www.nerds-central.blogspot.com www.project-network.com -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: 03 September 2006 17:20 To: Alex Turner; php-general@lists.php.net Subject: RE: [PHP] Crazy behavior... [snip] Can you send an example of the broken HTML? What are the symptoms of the html being broken. Finally, in what way are you using AJAX. This looks like html output - so is it really AJAH? My first guess is that something about the context at the browser end makes - an empty table element - cause trouble. Cheers AJ [/snip] This is really odd. I wrote the $html variable that I send back to the browser via AJAX, and that code is like this when I pushed it into a temporary database table: Close Nameasdf Description Assigned to Created byPeter Lauri(Farang) Due date Start date PriorityNormal Creation dateSun, 03 Sep 2006 23:09:44 +0700 However, if I just use that output all is shown until the empty tag. Then I tried to check what is actually captured by the browser, and it was showing only until the and then nothing more. So this should maybe be posted to the JavaScript list :) I have temporary solved by NOT allowing empty strings into those fields, but the description should be able to be empty :) /Peter -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] local php.ini not recognized in php 5.1.x?
Marten, I have also been trying to figure this out. Have you came to any conclusions? I have done some searching and so far haven't found any answers. Is there anyone else on the list that can shed some light on this? Thanks! -- Aaron Marten Lehmann wrote: > Hello, > > we switched from php 5.0.6 to 5.1.6. php is running as CGI. We have a global > php.ini in the /lib directory of the php installation with settings that are > valid for all users. > > In php 5.0.6 (and previous php releases) additionally the local php.ini in the > directory of the executed php-script has been parsed so users could overwrite > options like register_globals. But now in php 5.1.6 this local php.ini doesn't > seem to be recognized at all, not any option in it is evaluated. > > Is there anything that changed from php 5.0.x to 5.1.x regarding the handling > of php.ini's? I don't have any idea what went wrong because I compiled php > 5.1.6 with the same options as php 5.0.6. > > Regards > Marten > > -- Aaron Axelsen [EMAIL PROTECTED] Great hosting, low prices. Modevia Web Services LLC -- http://www.modevia.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Crazy behavior...
Peter, That is very odd! When you say 'breaks' do you mean, just stops? Is it possible that a 0x00 character is getting in there somehow? It would be good to actually see what is going between the client and the server. Have you ever used JMeter? If you were to proxy between the two with JMeter then we would have an 'independent third party' to see what is going on. Cheers - and good sleeping! AJ Alexander J Turner Ph.D. www.deployview.com www.nerds-central.blogspot.com www.project-network.com -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: 03 September 2006 18:02 To: Alex Turner Cc: php-general@lists.php.net Subject: RE: [PHP] Crazy behavior... Just thought one thing. I did do a alert() on the http.responseText, and that breaks in on the too, so the response that is sent back probably just ends there... weird... /Peter -Original Message- From: Alex Turner [mailto:[EMAIL PROTECTED] Sent: Sunday, September 03, 2006 11:31 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: RE: [PHP] Crazy behavior... Peter, When it arrives at the browser, via ajax, I am guessing that you then put it into the page view .innerHTML or some other method. I suspect your problem revolves around asking the browser to do stuff it should not really have to do. There are two issues I would like to highlight with the html. 1) You are mixing TH and TD on the same row. You should be using styles to set the different presentations of the elements. 2) You have placed a paragraph section between the table tag and the first tr tag. This is wrong. I suspect that the browser is managing to cope with this markup when presented as a static page but is unable to figure out how to update an existing page with it. If you fix the html to be standards compliant then the chances are all will be well. If it is not - by all means get back to me :-) Best wishes AJ Alexander J Turner Ph.D. www.deployview.com www.nerds-central.blogspot.com www.project-network.com -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: 03 September 2006 17:20 To: Alex Turner; php-general@lists.php.net Subject: RE: [PHP] Crazy behavior... [snip] Can you send an example of the broken HTML? What are the symptoms of the html being broken. Finally, in what way are you using AJAX. This looks like html output - so is it really AJAH? My first guess is that something about the context at the browser end makes - an empty table element - cause trouble. Cheers AJ [/snip] This is really odd. I wrote the $html variable that I send back to the browser via AJAX, and that code is like this when I pushed it into a temporary database table: Close Nameasdf Description Assigned to Created byPeter Lauri(Farang) Due date Start date PriorityNormal Creation dateSun, 03 Sep 2006 23:09:44 +0700 However, if I just use that output all is shown until the empty tag. Then I tried to check what is actually captured by the browser, and it was showing only until the and then nothing more. So this should maybe be posted to the JavaScript list :) I have temporary solved by NOT allowing empty strings into those fields, but the description should be able to be empty :) /Peter -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php