[PHP] scroll down list -visible, but not possible to choose
Hi, Got so excellent and fast help last time so trying again here I have the below function with array for satus of issues where I need to have 'Resolved/Closed' visible but not available for choice This as closing is a separate function to ensure correct resolution code is selected Already tried removing 'Resolved', and got everything working only to notice when testing that when viewing issues the Resolved ones showed up as 'Support Working' even though closed in the system function print_statuses($selected) { $statuses = array('Resolved','Support Working','Waiting on Customer','New','Read Update'); foreach($statuses as $status) { echo "$status"; } }
[PHP] mysqli sql question
Is it possible to get the actual sql that is being used to query or update the database? E.g $sth = $dbh->prepare ("update table set field=?, field2=? where id=?); mysqli_bind_param ($sth, 'ssi', 'text1', 'text2', 10); $sth->execute(); Something like $sth->sql? Or $dbh->sql? I want to see "update table set field='text1', field2='text2' where id=10; Thanks in advance, Peet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] scroll down list -visible, but not possible to choose
> Date: Wed, 31 Aug 2011 04:30:56 -0400 > From: rob...@myself.com > To: php-general@lists.php.net > Subject: [PHP] scroll down list -visible, but not possible to choose > > Hi, > Got so excellent and fast help last time so trying again here > > I have the below function with array for satus of issues where I need to > have 'Resolved/Closed' visible but not available for choice > This as closing is a separate function to ensure correct resolution code is > selected > > Already tried removing 'Resolved', and got everything working only to notice > when testing that when viewing issues the Resolved > ones showed up as 'Support Working' even though closed in the system > > > function print_statuses($selected) { > $statuses = array('Resolved','Support Working','Waiting on > Customer','New','Read Update'); > foreach($statuses as $status) { > echo " if($status == $selected) echo ' selected'; > echo ">$status"; > } > } The HTML attribute 'disabled' for the option tag might help you out here. Another option would be to catch off selection of the 'Resolved' state when parsing the submission of the form. Lastly you could alter the script to display something else instead of the selection box when the 'Resolved' state applies. Personally I think the latter is the most elegant solution. Regards, Jasper
Re: [PHP] mysqli sql question
On 31.08.2011 11:23, Peet Grobler wrote: Is it possible to get the actual sql that is being used to query or update the database?> E.g $sth = $dbh->prepare ("update table set field=?, field2=? where id=?); mysqli_bind_param ($sth, 'ssi', 'text1', 'text2', 10); $sth->execute(); Something like $sth->sql? Or $dbh->sql? Thanks in advance, Peet Hi Peet, not sure if there is a method to echo the sql but you can set your development MySQL server to log all queries to a log file. Use the log file with tail and you'll get a live view of all queries the server attempts to process. Open my.cnf / my.ini and add the following line: log= "/path/to/log/mysqld_query.log" or log="D:\logs\mysqld_query.log" More info here: http://dev.mysql.com/doc/refman/5.1/en/query-log.html I hope this helps ... ohh and don't forget to clear the log every now and then because it will get HUGE quickly. -- John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqli sql question
On 08/31/2011 05:23 AM, Peet Grobler wrote: > Is it possible to get the actual sql that is being used to query or > update the database? > > E.g > $sth = $dbh->prepare ("update table set field=?, field2=? where id=?); > mysqli_bind_param ($sth, 'ssi', 'text1', 'text2', 10); > $sth->execute(); > > Something like $sth->sql? Or $dbh->sql? > > I want to see "update table set field='text1', field2='text2' where id=10; > > > Thanks in advance, > Peet > Look up the EXPLAIN SQL function call. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] utf8_decode() not working, conflicts with urlencode()
Am 30.08.2011 12:11, schrieb Per Jessen: Merlin Morgenstern wrote: Hi there, I am having some trouble with utf8_decode(). Somehow the function returns output=input e.g.: $input = '%20%C3%9Cbersetzung%20franz'; $output = utf8_decode($input); echo $input.''.$output; My goal is to decode the utf8, trim the input and encode with urlencode(); This is the string which I would like to get: %C3%9Cbersetzung+franz Trim does not work and if I place urlencode() directly on the input it will encode the % sign to %25 and produce therfore a mixture of encodings. It seems to me that you're probably missing a urldecode() on $input before you attempt to decode the utf8 chars ? that is true, thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Hide php action pages from google
Hi there, I do have a search form on my site which posts search queries to follogin URL: /subapp_search/search.php Depending on the search parameters it will then redirect to the appropriate URL. e.g.: /suche/labrador I now discovered in google webmastertools that this very page (search.php) is listed there as a reference for the speed of the whole page with 2.7s. This page should be irrelevant to google. Does somebody know how to hide it from google? All redirects coming from there are 301s and the page without parameters redirects to / Thank you for any help on that, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqli sql question
On 8/31/2011 1:38 PM, John Black wrote: > Hi Peet, > > not sure if there is a method to echo the sql but you can set your > development MySQL server to log all queries to a log file. > Use the log file with tail and you'll get a live view of all queries the > server attempts to process. > I already have this on the development system. I'm looking for something for the live system that displays the SQL if a query fails (this is done in an email to the developer's mailing list) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code should be selv-maintaining!
Genius! -Original Message- From: Matt Graham [mailto:danceswithcr...@usa.net] Sent: Tuesday, August 30, 2011 5:59 PM To: php-general@lists.php.net Subject: Re: [PHP] Code should be selv-maintaining! From: David Harkness > I don't always use braces, but when I do I use Compact Control Readability > style. Stay coding, my friends. ...and when you use CCR style, you can sing, "I see a bad brace a-risin'"? -- Matt G / Dances With Crows The Crow202 Blog: http://crow202.org/wordpress/ There is no Darkness in Eternity/But only Light too dim for us to see -- 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] mysqli sql question
Peet, Could you do something like this instead? This is using named placeholders and a separate line for your statement but I was able to get it to echo the statement in this manner. $sql = "UPDATE table SET field1=:field1, field2=:field2 WHERE id=:id"; $sth = $dbh->prepare($sql); $sth->execute(array(":field1"=>$field1, ": field2"=>$ field2, ": id"=>$id)); echo $sql; Hope that helps, Jen -Original Message- From: Peet Grobler [mailto:p...@hivemind.net] Sent: Wednesday, August 31, 2011 4:24 AM To: php-general@lists.php.net Subject: [PHP] mysqli sql question Is it possible to get the actual sql that is being used to query or update the database? E.g $sth = $dbh->prepare ("update table set field=?, field2=? where id=?); mysqli_bind_param ($sth, 'ssi', 'text1', 'text2', 10); $sth->execute(); Something like $sth->sql? Or $dbh->sql? I want to see "update table set field='text1', field2='text2' where id=10; Thanks in advance, Peet -- 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] Hide php action pages from google
Merlin, Do you have a robots.txt file in your root folder? A text document named robots.txt in your document root containing the following text should solve your problem. # robots.txt for http://www.yourdomain.com/ User-agent: * Disallow: /subapp_search/search.php User-Agent: Googlebot Disallow: /subapp_search/search.php More info here: http://www.google.com/support/webmasters/bin/answer.py?answer=156449 Jen -Original Message- From: Merlin Morgenstern [mailto:merlin.morgenst...@googlemail.com] Sent: Wednesday, August 31, 2011 7:39 AM To: php-general@lists.php.net Subject: [PHP] Hide php action pages from google Hi there, I do have a search form on my site which posts search queries to follogin URL: /subapp_search/search.php Depending on the search parameters it will then redirect to the appropriate URL. e.g.: /suche/labrador I now discovered in google webmastertools that this very page (search.php) is listed there as a reference for the speed of the whole page with 2.7s. This page should be irrelevant to google. Does somebody know how to hide it from google? All redirects coming from there are 301s and the page without parameters redirects to / Thank you for any help on that, Merlin -- 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] Bug #51739 tricky string to float conversion
Hi, I have opend Bug #51739 in 2010. It was closed as bogus before my last question was answered. It would be fine to know what you think about that bug. In short: var_dump((float)"8315e839da08e2a7afe6dd12ec58245d"); results in float(INF) This is because "8315" is treated as base and "e839da08e2a7afe6dd12ec58245d" is treated as an exponent. My hint that "e839da08e2a7afe6dd12ec58245d" is not a valid exponent was not answered. What do you think about? cheers Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysqli sql question
"Jen Rasmussen" writes: > Peet, > > Could you do something like this instead? This is using named placeholders > and a separate line for your statement > but I was able to get it to echo the statement in this manner. > > $sql = "UPDATE table SET field1=:field1, field2=:field2 WHERE id=:id"; > $sth = $dbh->prepare($sql); > $sth->execute(array(":field1"=>$field1, > ": field2"=>$ field2, > ": id"=>$id)); Hi Jen, could you point me to a document/man page for PHP which explains that : notation in $sql= line please. I'm sure its common to everyone here but, well, I never saw it before ;( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysqli sql question
Hi there Richard It's part of the prepared statements http://php.net/manual/de/pdo.prepared-statements.php ;) 2011/8/31 Richard Riley > "Jen Rasmussen" writes: > > > Peet, > > > > Could you do something like this instead? This is using named > placeholders > > and a separate line for your statement > > but I was able to get it to echo the statement in this manner. > > > > $sql = "UPDATE table SET field1=:field1, field2=:field2 WHERE id=:id"; > > $sth = $dbh->prepare($sql); > > $sth->execute(array(":field1"=>$field1, > > ": field2"=>$ field2, > > ": id"=>$id)); > > Hi Jen, could you point me to a document/man page for PHP which explains > that : notation in $sql= line please. I'm sure its common to everyone > here but, well, I never saw it before ;( > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: Re: [PHP] Re: mysqli sql question
> Original Message >From: Louis Huppenbauer >To: php-general@lists.php.net >Sent: Wed, Aug 31, 2011, 10:24 AM >Subject: Re: [PHP] Re: mysqli sql question > >Hi there Richard > >It's part of the prepared statements >http://php.net/manual/de/pdo.prepared-statements.php >;) > >2011/8/31 Richard Riley > >> "Jen Rasmussen" writes: >> >> > Peet, >> > >> > Could you do something like this instead? This is using named >> placeholders >> > and a separate line for your statement >> > but I was able to get it to echo the statement in this manner. >> > >> > $sql = "UPDATE table SET field1=:field1, field2=:field2 WHERE id=:id"; >> > $sth = $dbh->prepare($sql); >> > $sth->execute(array(":field1"=>$field1, >> > ": field2"=>$ field2, >> > ": id"=>$id)); >> >> Hi Jen, could you point me to a document/man page for PHP which explains >> that : notation in $sql= line please. I'm sure its common to everyone >> here but, well, I never saw it before ;( >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> These are called SQL Parameters. It's recommended to use them since they help eliminate SQL Injections. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: mysqli sql question
Peet, Here is the PHP PDO link: http://php.net/manual/en/book.pdo.php If you look on example #2 on this page: http://www.php.net/manual/en/pdostatement.execute.php That is pretty much how it's setup (although the example I gave is update, this is select). And please correct me I said the provided code example included named placeholders, apparently correct terminology is named parameters. I found this to be a great article as well: http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-d atabase-access/ If you need some more example code as well, just let me know. I've been up to my ears in PDO the last several weeks. Jen -Original Message- From: Richard Riley [mailto:rile...@googlemail.com] Sent: Wednesday, August 31, 2011 9:18 AM To: php-general@lists.php.net Subject: [PHP] Re: mysqli sql question "Jen Rasmussen" writes: > Peet, > > Could you do something like this instead? This is using named placeholders > and a separate line for your statement > but I was able to get it to echo the statement in this manner. > > $sql = "UPDATE table SET field1=:field1, field2=:field2 WHERE id=:id"; > $sth = $dbh->prepare($sql); > $sth->execute(array(":field1"=>$field1, > ": field2"=>$ field2, > ": id"=>$id)); Hi Jen, could you point me to a document/man page for PHP which explains that : notation in $sql= line please. I'm sure its common to everyone here but, well, I never saw it before ;( -- 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] scroll down list -visible, but not possible to choose
You want: > if($status == $selected) echo "selected = ' selected' "; (I didn't bother with \s) And BTW, unless the support person is actually sitting on top of the customer (and I can see situations where that would help), you want it to say "Waiting *for* Customer" Ken On Wed, Aug 31, 2011 at 3:30 AM, wrote: > echo " if($status == $selected) echo ' selected'; > echo ">$status"; > } > } > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Bug #51739 tricky string to float conversion
On 08/31/2011 09:03 AM, magic-...@damage.devloop.de wrote: > Hi, > I have opend Bug #51739 in 2010. It was closed as bogus before my last > question was answered. It would be fine to know what you think about > that bug. > In short: > var_dump((float)"8315e839da08e2a7afe6dd12ec58245d"); > results in float(INF) > This is because "8315" is treated as base and > "e839da08e2a7afe6dd12ec58245d" is treated as an exponent. My hint that > "e839da08e2a7afe6dd12ec58245d" is not a valid exponent was not answered. > What do you think about? > cheers > Daniel The cast to float is truncating the invalid characters and since your string contains a float that is INF (8315e839) before the truncation at the "d", then it returns INF. Makes perfect sense. -- 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] scroll down list -visible, but not possible to choose
On Wed, 31 Aug 2011, rob...@myself.com wrote: I have the below function with array for satus of issues where I need to have 'Resolved/Closed' visible but not available for choice This as closing is a separate function to ensure correct resolution code is selected Already tried removing 'Resolved', and got everything working only to notice when testing that when viewing issues the Resolved ones showed up as 'Support Working' even though closed in the system There are two possible points of failure here, your code and browser behaviour. Whenever I'm faced with this sort of problem, I look at the source code in my browser to see the HTML my code generates. Then I can determine if my code is outputting what I'd intended. If it is, then my code is right but the implementation is wrong, as the correct HTML produces the incorrect result. If you'd done this, you'd have seen what the problem is. The problem is that, having taken away "Resolved" as a possible option, all items marked "Resolved" are unable to be listed as selected. Consequently no items are selected and the browser defaults to the first item in the list which is "Support Working". I've never had to do this, but http://www.w3schools.com/TAGS/tag_option.asp says you can use the "disabled" attribute to disable an option. So your resulting HTML could look like this: Resolved or Resolved as appropriate. A simple if statement could be used to set the "disabled" attribute for the "Resolved" selection only. IMHO this is vastly preferable to any trickery you may use with javascript to prevent the user from selecting Resolved. I've never struck a select field like this and am now interested in coding one up just to see how it works in practice. HTH, Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Bug #51739 tricky string to float conversion
On 08/31/2011 01:48 PM, Shawn McKenzie wrote: > > The cast to float is truncating the invalid characters and since your > string contains a float that is INF (8315e839) before the truncation at > the "d", then it returns INF. Makes perfect sense. > Just FYI... Don't post your troubles or misunderstandings as bug reports. The PHP developers sift through too many reports as it is and many or maybe the majority are "support" tickets like yours that are not "bugs". The people assigned to bugs are not going to explain why your issue is not a bug in detail. They are tasked with fixing bugs, and they have many bug reports (mostly like yours). The appropriate place for you to post would be here on this list first. If the consensus of the veteran folks on this list is "wow, that's a bug" or some such, then we will tell you to post a bug report. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mysqli error handling
Okay, so I've finally got an opportunity to start converting our code to use Mysqli instead of the old mysql_* functions. Mysqli is new to me, but I thought things were going well until the first time I tried to run a query with a syntax error in it, and it threw up a PHP warning. Being that Mysqli is an OO API, I guess I assumed that any errors would simply surface as exceptions, and indeed, I got an exception in this case. But I also got a PHP warning containing the same information. This is the first thing that strikes me as terribly wrong. I think any API, OO or not, should never spit out errors/warnings/notices for routine errors (like, in this case, an SQL syntax error). Rather, the function/method should signal an error through a defined mechanism, such as the return value (e.g., false on failure), or via an exception for class methods. This philosophy jives well with my understand of the direction of error handling in PHP, which is to use exceptions, rather than errors/warnings/notices, for all the newer OOP APIs. Secondly, I can't find a good way to handle these warnings. We do all development with error handling set to E_STRICT | E_ALL, and our general policy is that no such errors should be generated. This behavior by Mysqli means that we effectively need to catch SQL problems in both our error handlers and in our exception handling. I recognize that we could just use suppression, but that's, well, nasty. Digging a bit more, I found mysqli_report(). This looks pretty good, but I find it odd that 1) it's a procedural-only function that controls an OO API, and 2), it takes affect for the entire request, which effectively means it has to be set up right for each database access rather than just once per database instance. I suspect this relates to the underlying implementation, but it's still quite the letdown. Is there something I'm missing in all this, or is really as clunky as it seems? What have those of you with more Mysqli experience found to work well as a good error-handling pattern when working with it? -- Robert E. Williams, Jr. Associate Vice President of Software Development Newtek Businesss Services, Inc. -- The Small Business Authority https://www.newtekreferrals.com/rewjr http://www.thesba.com/ Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or if you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote: > On 11-08-30 11:36 AM, Richard Quadling wrote: >> On 30 August 2011 15:04, Tedd Sperling wrote: >>> To all: >>> >>> I prefer the Whitesmiths style: >>> >>> http://rebel.lcc.edu/sperlt/citw229/brace-styles.php >>> >>> But "style" is really up to the individual -- what works best for you is >>> the "best" (unless it's a team effort or the clients demand). >>> >>> Cheers, >>> >>> tedd >> >> At last Someone's code I could read without having to reformat it >> every bloody time!!! >> >> http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style > > You're just saying that so Tedd will be your friend!! Come now, let's be > honest with everyone... Whitesmith's is -GLEE! ;) > > Cheers, > Rob. No, not indenting braces is T LYY. Make things uniform -- a condition followed by indented code located between equally indented braces makes sense to me. How people read other code styles is a mystery to me. Cheers, tedd _ t...@sperling.com http://sperling.com
Re: [PHP] Re: [EasyPHP] How to export and import `alias` from previous version of EasyPHP?
Dear Danial, I saw some update on EasyPHP via this group so I just thought to receive support as well as such advertisement. I'm sorry to "spam" this group. Regards. On Mon, Aug 29, 2011 at 7:26 PM, Daniel Brown wrote: > On Sun, Aug 28, 2011 at 07:10, EasyPHP wrote: > > Hi > > > > Open your old conf_files/httpd.conf, copy the end of the file (between > > #alias) and paste it in the new one. > > Restart the servers. That's it! > > Please keep EasyPHP-specific support requests off this list, and > on a list, forum, or other support channel exclusively for that > product. It is a derivative of PHP, but it unrelated and should not > be discussed here. > >Thanks. > > -- > > Network Infrastructure Manager > http://www.php.net/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Nam
Re: [PHP] Code should be selv-maintaining!
On Wed, Aug 31, 2011 at 08:20:14PM -0400, Tedd Sperling wrote: > On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote: > > > On 11-08-30 11:36 AM, Richard Quadling wrote: > >> On 30 August 2011 15:04, Tedd Sperling > >> wrote: > >>> To all: > >>> > >>> I prefer the Whitesmiths style: > >>> > >>> http://rebel.lcc.edu/sperlt/citw229/brace-styles.php > >>> > >>> But "style" is really up to the individual -- what works best for > >>> you is the "best" (unless it's a team effort or the clients > >>> demand). > >>> > >>> Cheers, > >>> > >>> tedd > >> > >> At last Someone's code I could read without having to reformat > >> it every bloody time!!! > >> > >> http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style > > > > You're just saying that so Tedd will be your friend!! Come now, > > let's be honest with everyone... Whitesmith's is -GLEE! > > ;) > > > > Cheers, Rob. > > No, not indenting braces is T > LYY. > > Make things uniform -- a condition followed by indented code located > between equally indented braces makes sense to me. > How people read > other code styles is a mystery to me. Indeed it is a mystery, a religious one. The way we do it is because we finally broke through the clouds of earthly obfuscation to comprehend the blinding truth that is K&R. Amen. (Nah, it wasn't Kool-Aid. Tasted more like a cross between RC Cola and Dr Pepper.) ;-} Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote: >I prefer the Whitesmiths style: > >http://rebel.lcc.edu/sperlt/citw229/brace-styles.php > >But "style" is really up to the individual -- what works best for you >is the "best" (unless it's a team effort or the clients demand). I note on your page that you prefer Whitesmiths (truly ugly!) style even for JavaScript. I'd strongly recommend against that, and also Allman style, due to semicolon insertion. e.g. (randomly selected from Google) http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/ Sure, instances of the problem are minimal, but if you're in the habit of Dangerous Open Brace Placement then you just might fall afoul of it. Besides, my editor (Geany) folds code mostly neatly with K&R :) -- Ross McKay, Toronto, NSW Australia "Let the laddie play wi the knife - he'll learn" - The Wee Book of Calvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 11-08-31 08:20 PM, Tedd Sperling wrote: On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote: On 11-08-30 11:36 AM, Richard Quadling wrote: On 30 August 2011 15:04, Tedd Sperling wrote: To all: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But "style" is really up to the individual -- what works best for you is the "best" (unless it's a team effort or the clients demand). Cheers, tedd At last Someone's code I could read without having to reformat it every bloody time!!! http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Cheers, Rob. No, not indenting braces is T LYY. Make things uniform -- a condition followed by indented code located between equally indented braces makes sense to me. How people read other code styles is a mystery to me. Come now Tedd! It's only Thursday and yet you jest so!! :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 2011-08-31, at 11:44 PM, Ross McKay wrote: > On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote: > >> I prefer the Whitesmiths style: >> >> http://rebel.lcc.edu/sperlt/citw229/brace-styles.php >> >> But "style" is really up to the individual -- what works best for you >> is the "best" (unless it's a team effort or the clients demand). > > I note on your page that you prefer Whitesmiths (truly ugly!) style even > for JavaScript. I'd strongly recommend against that, and also Allman > style, due to semicolon insertion. e.g. (randomly selected from Google) > > http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ > http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/ > > Sure, instances of the problem are minimal, but if you're in the habit > of Dangerous Open Brace Placement then you just might fall afoul of it. > > Besides, my editor (Geany) folds code mostly neatly with K&R :) --- FWIW, am working my way through an O'Reilly book (HTML5 Canvas) right now and they appear to use The One True Brace Style in their code examples. Not religious about it, but it does help me know which code I wrote and what was touched by someone else! George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 11-09-01 01:44 AM, Ross McKay wrote: On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote: I prefer the Whitesmiths style: http://rebel.lcc.edu/sperlt/citw229/brace-styles.php But "style" is really up to the individual -- what works best for you is the "best" (unless it's a team effort or the clients demand). I note on your page that you prefer Whitesmiths (truly ugly!) style even for JavaScript. I'd strongly recommend against that, and also Allman style, due to semicolon insertion. e.g. (randomly selected from Google) http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/ Sure, instances of the problem are minimal, but if you're in the habit of Dangerous Open Brace Placement then you just might fall afoul of it. Besides, my editor (Geany) folds code mostly neatly with K&R :) That's because JavaScript is broken in some ways. As much as I like JavaScript, some parts of the language were thrown together by flinging crap at a fan and seeing what sticks to the wall... this being a prime example. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
Robert Cummings wrote: >That's because JavaScript is broken in some ways. As much as I like >JavaScript, some parts of the language were thrown together by flinging >crap at a fan and seeing what sticks to the wall... this being a prime >example. Sounds a lot like PHP :) which I must add I love dearly, though it certainly resembles your remark much more closely than JavaScript. But on-topic, novices using a coding style and feeling their way around a new language would be better served by the 1TB style than anything that easily allows statement insertion (either by them, or by silly language defects like JavaScript's semicolon insertion). -- Ross McKay, Toronto, NSW Australia "Hold very tight please! Ting! Ting!" - Flanders and Swann -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php