Re: [PHP] Array Symbol Suggestion
Donovan Brooke wrote: > however, from my experience, there is often this kind of problem in > any language, and that is where naming conventions come in very handy. > > I don't know if the PHP community has any standard convention.. One popular naming convention: http://en.wikipedia.org/wiki/Hungarian_notation -- Per Jessen, Zürich (7.8°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
Ashley Sheridan wrote: > On Wed, 2011-01-12 at 12:23 -0800, sono...@fannullone.us wrote: > >> Thanks for all the responses to my suggestion. I realize this would >> be a major change, so that's why I also mentioned it as an addition >> to the language. >> >> I'm sure it's just what you're used to, but still being new to all >> this, it just makes sense (to me anyway) to have different symbols >> for different variable types: $scalar @array >> #hash >> >> Since the @ sign is already reserved, maybe there's another symbol >> that would work better? I don't know. These are just ideas that I >> came up with while reading and I thought I'd throw it out there to >> see what others thought. >> >> I like the idea of a naming convention, so that's what I'll do in my >> scripts. I also appreciate the heads up on is_string(), is_array(), >> and var_dump(). >> >> Thanks again, >> Marc > > > If you check out the manual pages for those functions as well, you'll > see other related functions. I must say, of any language I've used, > the php.net documentation is by far the best, giving plenty of > information and user comments too. It's a resource I still can't do > without, and I reckon even the old hands on this list would say the > same. Yes, I wouldn't want to be without my local php.net mirror. Other languages that can easily match the quality of the documentation - assembler, C and C++, to name a few. -- Per Jessen, Zürich (7.9°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closure and $this
On Wednesday, January 12, 2011 11:37:19 pm Greg Bair wrote: > On Wed, 12 Jan 2011 20:02:11 -0800 (PST) > > Raymond Irving wrote: > > Hello, > > Does anyone know if closures will ever support the $this keyword? > > I think it would be very useful when working with objects. > > > > Best regards__RaymondDo more with less - http://raxanpdi.com > > Probably not, and my understanding of why comes from this line from the > docs (http://www.php.net/manual/en/functions.anonymous.php): > > "Anonymous functions are currently implemented using the Closure class." > > So, in other words, your closure does not belong to the class you > declare it in, but the Closure class. > > Thus, if it supported the $this variable, it would refer not to the > class you want, but instead to the Closure class. > > Just my understanding. If it's not right, someone point it out. Actually at one point early on they did support a $this, but the way it was bound to an object was half-assed and incomplete so it was removed entirely from 5.3. The intent was to then properly think through how that binding should happen and re-introduce it properly in 5.4. I believe a consensus was reached on how that should happen but I'm not sure what its implementation status is at present. I believe this is the relevant RFC: http://wiki.php.net/rfc/closures/object-extension --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closure and $this
On Wed, 12 Jan 2011 20:02:11 -0800 (PST) Raymond Irving wrote: > Hello, > Does anyone know if closures will ever support the $this keyword? > I think it would be very useful when working with objects. > > Best regards__RaymondDo more with less - http://raxanpdi.com > Probably not, and my understanding of why comes from this line from the docs (http://www.php.net/manual/en/functions.anonymous.php): "Anonymous functions are currently implemented using the Closure class." So, in other words, your closure does not belong to the class you declare it in, but the Closure class. Thus, if it supported the $this variable, it would refer not to the class you want, but instead to the Closure class. Just my understanding. If it's not right, someone point it out. -- Greg Bair PHP Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Closure and $this
Hello, Does anyone know if closures will ever support the $this keyword? I think it would be very useful when working with objects. Best regards__RaymondDo more with less - http://raxanpdi.com
Re: [PHP] projectpier
At least now we all know of the domainname change xD Sent from my iPhone On 12-01-2011, at 19:38, Peter Lind wrote: > 2011/1/12 Ashley Sheridan > >> On Wed, 2011-01-12 at 23:14 +0100, Peter Lind wrote: >> >> jeg har flyttet projectpier over paa fastaval.dk domaenet - >> det koerer nu under pp.fastaval.dk. Der er ogsaa sat redirects op paa >> fastaval.plphp.dk saa man skulle ikke kunne komme til det gamle site >> (og dermed ikke logge ind det forkerte sted) >> >> >> I think perhaps your change in domains was not meant to be posted to the >> list? :p >> >> > There's a massive ooops! if ever I did see one. Sorry about the (unintended) > noise and thanks for letting me know. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] projectpier
2011/1/12 Ashley Sheridan > On Wed, 2011-01-12 at 23:14 +0100, Peter Lind wrote: > > jeg har flyttet projectpier over paa fastaval.dk domaenet - > det koerer nu under pp.fastaval.dk. Der er ogsaa sat redirects op paa > fastaval.plphp.dk saa man skulle ikke kunne komme til det gamle site > (og dermed ikke logge ind det forkerte sted) > > > I think perhaps your change in domains was not meant to be posted to the > list? :p > > There's a massive ooops! if ever I did see one. Sorry about the (unintended) noise and thanks for letting me know.
Re: [PHP] projectpier
On Wed, 2011-01-12 at 23:14 +0100, Peter Lind wrote: > jeg har flyttet projectpier over paa fastaval.dk domaenet - > det koerer nu under pp.fastaval.dk. Der er ogsaa sat redirects op paa > fastaval.plphp.dk saa man skulle ikke kunne komme til det gamle site > (og dermed ikke logge ind det forkerte sted) I think perhaps your change in domains was not meant to be posted to the list? :p Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] projectpier
Heads up: jeg har flyttet projectpier over paa fastaval.dk domaenet - det koerer nu under pp.fastaval.dk. Der er ogsaa sat redirects op paa fastaval.plphp.dk saa man skulle ikke kunne komme til det gamle site (og dermed ikke logge ind det forkerte sted). -- WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
If you are going to use double quotes escape out. >> echo "".$replace.""; On Jan 12, 2011, at 2:30 PM, tedd wrote: > At 10:35 PM -0500 1/11/11, David McGlone wrote: >> Hi Everyone, I'm having a problem validating some links I have in a foreach. >> Here is my code: >> > "http://www.w3.org/TR/html4/loose.dtd";> >> >> my PHP code: >> $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', >> 'testimonials'); >> foreach($categorys as $category){ >> $replace = str_replace("_", " ", $category); >> echo "$replace"; >> } >> >> Validator Error: >> an attribute value must be a literal unless it contains only name characters >> >> Šome>homeservices> hŠ >> >> I have tried various combinatons and different doctypes. I'm beginning to >> wonder if this code is allowed at all. >> >> >> -- >> Blessings >> David M. > > David: > > First of all, the type (strict or transitional) of DOCTYPE doesn't matter -- > it only matters IF you are going to use deprecated HTML elements > (transitional) or not (strict). > > Second, your (i.e., list) should start with a "type of list" tag, such > for ordered list -- there are several different types (i.e., ol, ul, > dir, menu, dl dt dd). > > Third, you might try this: > > echo("$replace"); > > The Validator might be objecting to the way you use ' instead of ". > > HTH's > > Cheers, > > tedd > > > -- > --- > http://sperling.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Wed, Jan 12, 2011 at 15:41, Michael Shadle wrote: > On Wed, Jan 12, 2011 at 12:37 PM, Daniel Brown wrote: > >> The @ is an error control operator, used to buffer the output and >> store it in a variable - $php_errormsg. There's no way that would be >> changed to become an array designator (though that doesn't mean your >> idea itself is a bad one). > > @ squelches error messages. > > AFAIK $php_errormsg is the last error that PHP incurred. not based on "@" Correct. The way I worded it makes it sound like @ is what populates the variable, which would be incorrect. Plus, I should also mention that $php_errormsg is only available if you enable track_errors anyway, which (if I remember correctly) is off by default. Thanks for pointing that out, Mike. -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Wed, Jan 12, 2011 at 12:37 PM, Daniel Brown wrote: > The @ is an error control operator, used to buffer the output and > store it in a variable - $php_errormsg. There's no way that would be > changed to become an array designator (though that doesn't mean your > idea itself is a bad one). @ squelches error messages. AFAIK $php_errormsg is the last error that PHP incurred. not based on "@" "@" just silences the errors from being reported, which is a "bad thing" as error collection is done even if error_reporting is off, it is still built internally as a string, that's why developing with E_ALL and E_STRICT even on is the best practice. even notices wind up adding to the internal error/etc. string stack. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Wed, Jan 12, 2011 at 14:45, wrote: > I'd like to make a suggestion for a change, or possibly an addition, to the > PHP language. > > I'm learning PHP and have been very excited with what it can do in relation > to HTML. But when I got to the part about arrays, I was disappointed to see > that they are designated with a $ the same as other variables. I was > learning Perl before I switched, and it uses the @ sign to designate an > array. That makes it a lot simpler to see at a glance what is an array and > what isn't - at least for beginners like me. > > Has there been any talk of adopting the @ sign for arrays in PHP? Or is that > symbol used for something else that I haven't read about yet? The @ is an error control operator, used to buffer the output and store it in a variable - $php_errormsg. There's no way that would be changed to become an array designator (though that doesn't mean your idea itself is a bad one). > What is the proper channel for making suggestions like this? Usually on the Internals mailing list (intern...@lists.php.net) or as a Feature Request in the bug tracker (http://bugs.php.net/). -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Jan 12, 2011, at 3:28 PM, Ashley Sheridan wrote: > If you check out the manual pages for those functions as well, you'll > see other related functions. I must say, of any language I've used, the > php.net documentation is by far the best, giving plenty of information > and user comments too. It's a resource I still can't do without, and I > reckon even the old hands on this list would say the same. > > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > I fully agree with you on php.net being some of the best documentation out there. I would say that a lot of the Java documentation is wonderfully done as well. It doesn't offer user comments, but it is very complete and covers just about every aspect of a class. Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Jan 12, 2011, at 3:23 PM, sono...@fannullone.us wrote: > Thanks for all the responses to my suggestion. I realize this would be a > major change, so that's why I also mentioned it as an addition to the > language. > > I'm sure it's just what you're used to, but still being new to all this, it > just makes sense (to me anyway) to have different symbols for different > variable types: > $scalar > @array > #hash > > Since the @ sign is already reserved, maybe there's another symbol that would > work better? I don't know. These are just ideas that I came up with while > reading and I thought I'd throw it out there to see what others thought. > > I like the idea of a naming convention, so that's what I'll do in my scripts. > I also appreciate the heads up on is_string(), is_array(), and var_dump(). > > Thanks again, > Marc > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > This would make sense to me for a compiled or strongly typed language, but no other language (that I've know of) uses this format. I haven't used Perl. In a dynamically typed language you normally have duck typed variables. # Python a = "Hello" b = 12 // JavaScript a = "Hello"; b = 12; c = [1, 2, 3]; // PHP $a = "Hello"; $b = 12; $c = array(1, 2, 3); Unless I'm misunderstanding the question? Regards, -Josh Joshua Kehn | josh.k...@gmail.com http://joshuakehn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Wed, 2011-01-12 at 12:23 -0800, sono...@fannullone.us wrote: > Thanks for all the responses to my suggestion. I realize this would be a > major change, so that's why I also mentioned it as an addition to the > language. > > I'm sure it's just what you're used to, but still being new to all this, it > just makes sense (to me anyway) to have different symbols for different > variable types: > $scalar > @array > #hash > > Since the @ sign is already reserved, maybe there's another symbol that would > work better? I don't know. These are just ideas that I came up with while > reading and I thought I'd throw it out there to see what others thought. > > I like the idea of a naming convention, so that's what I'll do in my scripts. > I also appreciate the heads up on is_string(), is_array(), and var_dump(). > > Thanks again, > Marc If you check out the manual pages for those functions as well, you'll see other related functions. I must say, of any language I've used, the php.net documentation is by far the best, giving plenty of information and user comments too. It's a resource I still can't do without, and I reckon even the old hands on this list would say the same. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Array Symbol Suggestion
Thanks for all the responses to my suggestion. I realize this would be a major change, so that's why I also mentioned it as an addition to the language. I'm sure it's just what you're used to, but still being new to all this, it just makes sense (to me anyway) to have different symbols for different variable types: $scalar @array #hash Since the @ sign is already reserved, maybe there's another symbol that would work better? I don't know. These are just ideas that I came up with while reading and I thought I'd throw it out there to see what others thought. I like the idea of a naming convention, so that's what I'll do in my scripts. I also appreciate the heads up on is_string(), is_array(), and var_dump(). Thanks again, Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Wed, 2011-01-12 at 20:58 +0100, Per Jessen wrote: > sono...@fannullone.us wrote: > > > I'd like to make a suggestion for a change, or possibly an addition, > > to the PHP language. > > > > I'm learning PHP and have been very excited with what it can do in > > relation to HTML. But when I got to the part about arrays, I was > > disappointed to see that they are designated with a $ the same as > > other variables. I was learning Perl before I switched, and it uses > > the @ sign to designate an array. That makes it a lot simpler to see > > at a glance what is an array and what isn't - at least for beginners > > like me. > > > > Has there been any talk of adopting the @ sign for arrays in PHP? Or > > is that symbol used for something else that I haven't read about yet? > > > > What is the proper channel for making suggestions like this? > > The php-development mailing list. What you're suggesting is a pretty > fundamental change, don't be disappointed if it is not met with > universal approval. > > > -- > Per Jessen, Zürich (5.9°C) > > not to mention, the @ symbol is a reserved character... an error control character[1]. So I dont think that using that char, would work. I dont see using it's own character to work at all, but in your own code, you can use your own naming conventions to denote what is an array, and what is a variable. Good luck with your suggestion, I personally wouldn't like it (as I am so used to the way it is now), but that is just me. Steve. [1] http://ca.php.net/manual/en/language.operators.errorcontrol.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
On Wed, 2011-01-12 at 11:45 -0800, sono...@fannullone.us wrote: > I'd like to make a suggestion for a change, or possibly an addition, to the > PHP language. > > I'm learning PHP and have been very excited with what it can do in relation > to HTML. But when I got to the part about arrays, I was disappointed to see > that they are designated with a $ the same as other variables. I was > learning Perl before I switched, and it uses the @ sign to designate an > array. That makes it a lot simpler to see at a glance what is an array and > what isn't - at least for beginners like me. > > Has there been any talk of adopting the @ sign for arrays in PHP? Or is that > symbol used for something else that I haven't read about yet? > > What is the proper channel for making suggestions like this? > > Thanks, > Marc PHP is a loosely typed language, so you can have a variable that, throughout its lifetime in an app, is both a scaler (integer, string, etc) or an array. For example: There are functions you can use to determine the type of a variable, such as is_string() and is_array() and you can use var_dump() in debug statements to quickly see the type of a variable. I think changing something as integral as a variable prefix would break a lot of code which makes use of the loose typing, and would cause much more confusion further down the line. Also, as you may have guessed, the @ symbol is already in use at the moment. In PHP it ensures that minor errors are silently ignored. For example: @executeSomeFunction() would run that named function, but ignore any minor errors and warnings. You'll typically find it used a lot in calls to mail() as that can be flaky on some systems due to a number of factors outside of PHP. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Array Symbol Suggestion
sono...@fannullone.us wrote: I'd like to make a suggestion for a change, or possibly an addition, to the PHP language. I'm learning PHP and have been very excited with what it can do in relation to HTML. But when I got to the part about arrays, I was disappointed to see that they are designated with a $ the same as other variables. I was learning Perl before I switched, and it uses the @ sign to designate an array. That makes it a lot simpler to see at a glance what is an array and what isn't - at least for beginners like me. Has there been any talk of adopting the @ sign for arrays in PHP? Or is that symbol used for something else that I haven't read about yet? What is the proper channel for making suggestions like this? Thanks, Marc Hi Marc, I'm a PHP n00b as well and had similar thoughts regarding this.. just imagine two variables called the same thing.. a string and array.. and accidentally resetting one.. $oops = "something"; however, from my experience, there is often this kind of problem in any language, and that is where naming conventions come in very handy. I don't know if the PHP community has any standard convention.. but I would suggest something like: $a_foo (for arrays) $f_foo (imploding into form variables) $s_foo (string variables) $db_foo (variables coming from databases perhaps) etc.. This way, you'd never be confused of the origin of the variable. Donovan -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Symbol Suggestion
sono...@fannullone.us wrote: > I'd like to make a suggestion for a change, or possibly an addition, > to the PHP language. > > I'm learning PHP and have been very excited with what it can do in > relation to HTML. But when I got to the part about arrays, I was > disappointed to see that they are designated with a $ the same as > other variables. I was learning Perl before I switched, and it uses > the @ sign to designate an array. That makes it a lot simpler to see > at a glance what is an array and what isn't - at least for beginners > like me. > > Has there been any talk of adopting the @ sign for arrays in PHP? Or > is that symbol used for something else that I haven't read about yet? > > What is the proper channel for making suggestions like this? The php-development mailing list. What you're suggesting is a pretty fundamental change, don't be disappointed if it is not met with universal approval. -- Per Jessen, Zürich (5.9°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array Symbol Suggestion
I'd like to make a suggestion for a change, or possibly an addition, to the PHP language. I'm learning PHP and have been very excited with what it can do in relation to HTML. But when I got to the part about arrays, I was disappointed to see that they are designated with a $ the same as other variables. I was learning Perl before I switched, and it uses the @ sign to designate an array. That makes it a lot simpler to see at a glance what is an array and what isn't - at least for beginners like me. Has there been any talk of adopting the @ sign for arrays in PHP? Or is that symbol used for something else that I haven't read about yet? What is the proper channel for making suggestions like this? Thanks, Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
At 10:35 PM -0500 1/11/11, David McGlone wrote: Hi Everyone, I'm having a problem validating some links I have in a foreach. Here is my code: http://www.w3.org/TR/html4/loose.dtd";> my PHP code: $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', 'testimonials'); foreach($categorys as $category){ $replace = str_replace("_", " ", $category); echo "$replace"; } Validator Error: an attribute value must be a literal unless it contains only name characters ome>homeservices David: First of all, the type (strict or transitional) of DOCTYPE doesn't matter -- it only matters IF you are going to use deprecated HTML elements (transitional) or not (strict). Second, your (i.e., list) should start with a "type of list" tag, such for ordered list -- there are several different types (i.e., ol, ul, dir, menu, dl dt dd). Third, you might try this: echo("$replace"); The Validator might be objecting to the way you use ' instead of ". HTH's Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
On Wed, Jan 12, 2011 at 12:08, David Harkness wrote: > > I tried this with PHP 5.3.2 on Ubuntu 10.04, but when I run any PHP script I > get the following. > > Fatal error in php.ini line 184: Saying a thing doesn't make it so. > > What does this mean? Looks like you may have installed the PECL extension PHP_BSDetect. -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
On Wed, Jan 12, 2011 at 6:04 AM, David McGlone wrote: > Prounouncing words for a deaf person is often times difficult. > That makes perfect sense. Think about it, > spelling isn't about remembering how to spell the word, but how to > prounounce > it. Not so fast! While this argument can be made to many facets of spelling, changing a "y" to "ie" when adding an "s" to make a word plural is 100% rule memorization and 0% pronunciation. In the interest of full disclosure I must point out that I typed "pronounciation" and didn't notice until the browser corrected me. *smack* :) On Tue, Jan 11, 2011 at 8:48 PM, Daniel Brown wrote: > To override this, you must uncomment the following line in your system's > php.ini: > >;human = true > I tried this with PHP 5.3.2 on Ubuntu 10.04, but when I run any PHP script I get the following. Fatal error in php.ini line 184: Saying a thing doesn't make it so. What does this mean? David
Re: [PHP] HTML errors
On 12 January 2011 14:07, Steve Staples wrote: > On Wed, 2011-01-12 at 13:40 +, Richard Quadling wrote: >> On 12 January 2011 13:20, Steve Staples wrote: >> > Jim, >> > >> > Not to be a smart ass like Danial was (which was brilliantly written >> > though), but you have your "example" formatted incorrectly. You are >> > using commas instead of periods for concatenation, and it would have >> > thrown an error trying to run your example. :) >> > >> > # corrected: >> > echo "{$replace}"; >> > >> > Steve Staples. >> >> Steve, >> >> The commas are not concatenation. They are separators for the echo construct. >> >> I don't know the internals well enough, but ... >> >> echo $a.$b.$c; >> >> vs >> >> echo $a, $b, $c; >> >> On the surface, the first instance has to create a temporary variable >> holding the results of the concatenation before passing it to the echo >> construct. >> >> In the second one, the string representations of each variable are >> added to the output buffer in order with no need to create a temp var >> first. >> >> So, I think for large strings, using commas should be more efficient. >> >> Richard. >> > > Well... I have been learned. I had no idea about doing it that way, I > apologize to you, Jim. > > I guess my PHP-fu is not as strong as I had thought? > > Thank you Richard for pointing out this to me, I may end up using this > method from now on. I have just always concatenated everything as a > force of habit. > > Steve Staples. > > I was never taught by nuns. -- 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] HTML errors
On Wed, 2011-01-12 at 13:40 +, Richard Quadling wrote: > On 12 January 2011 13:20, Steve Staples wrote: > > Jim, > > > > Not to be a smart ass like Danial was (which was brilliantly written > > though), but you have your "example" formatted incorrectly. You are > > using commas instead of periods for concatenation, and it would have > > thrown an error trying to run your example. :) > > > > # corrected: > > echo "{$replace}"; > > > > Steve Staples. > > Steve, > > The commas are not concatenation. They are separators for the echo construct. > > I don't know the internals well enough, but ... > > echo $a.$b.$c; > > vs > > echo $a, $b, $c; > > On the surface, the first instance has to create a temporary variable > holding the results of the concatenation before passing it to the echo > construct. > > In the second one, the string representations of each variable are > added to the output buffer in order with no need to create a temp var > first. > > So, I think for large strings, using commas should be more efficient. > > Richard. > Well... I have been learned. I had no idea about doing it that way, I apologize to you, Jim. I guess my PHP-fu is not as strong as I had thought? Thank you Richard for pointing out this to me, I may end up using this method from now on. I have just always concatenated everything as a force of habit. Steve Staples. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
On Wednesday, January 12, 2011 08:43:35 am Daniel Brown wrote: > On Wed, Jan 12, 2011 at 06:38, David McGlone wrote: > > Goes to show ya, even Deaf people aren't perfect spellers. Still like > > your little joke? ;-) > > Of course I do. Deafness has nothing to do with spelling. If it > did, just imagine how ridiculously difficult it would've been to > decipher anything Helen Keller ever wrote. Prounouncing words for a deaf person is often times difficult. Think about it, spelling isn't about remembering how to spell the word, but how to prounounce it. Also, Hellen Keller had a proof reader. :-) All in all, I was only kidding around with ya about this one to justify my stupid mistake in a funny way, but please do remember, it's difficult for deaf people to spell correctly because they prounounce a lot of words wrong. -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
On 12 January 2011 13:43, Daniel Brown wrote: > On Wed, Jan 12, 2011 at 06:38, David McGlone wrote: >> >> Goes to show ya, even Deaf people aren't perfect spellers. Still like your >> little joke? ;-) > > Of course I do. Deafness has nothing to do with spelling. If it > did, just imagine how ridiculously difficult it would've been to > decipher anything Helen Keller ever wrote. > And now I have "Tommy" playing in my head -- 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] HTML errors
On Wed, Jan 12, 2011 at 06:38, David McGlone wrote: > > Goes to show ya, even Deaf people aren't perfect spellers. Still like your > little joke? ;-) Of course I do. Deafness has nothing to do with spelling. If it did, just imagine how ridiculously difficult it would've been to decipher anything Helen Keller ever wrote. -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
On 12 January 2011 13:20, Steve Staples wrote: > Jim, > > Not to be a smart ass like Danial was (which was brilliantly written > though), but you have your "example" formatted incorrectly. You are > using commas instead of periods for concatenation, and it would have > thrown an error trying to run your example. :) > > # corrected: > echo "{$replace}"; > > Steve Staples. Steve, The commas are not concatenation. They are separators for the echo construct. I don't know the internals well enough, but ... echo $a.$b.$c; vs echo $a, $b, $c; On the surface, the first instance has to create a temporary variable holding the results of the concatenation before passing it to the echo construct. In the second one, the string representations of each variable are added to the output buffer in order with no need to create a temp var first. So, I think for large strings, using commas should be more efficient. Richard. -- 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] HTML errors
On Tue, 2011-01-11 at 23:38 -0800, Jim Lucas wrote: > On 1/11/2011 7:35 PM, David McGlone wrote: > > Hi Everyone, I'm having a problem validating some links I have in a foreach. > > Here is my code: > >> "http://www.w3.org/TR/html4/loose.dtd";> > > > > my PHP code: > > $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', > > 'testimonials'); > > foreach($categorys as $category){ > > $replace = str_replace("_", " ", $category); > > echo "$replace"; > > Try this instead > > echo '',$replace,''; > > Jim Lucas [snip] Jim, Not to be a smart ass like Danial was (which was brilliantly written though), but you have your "example" formatted incorrectly. You are using commas instead of periods for concatenation, and it would have thrown an error trying to run your example. :) # corrected: echo "{$replace}"; Steve Staples. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
On Tuesday, January 11, 2011 11:48:33 pm Daniel Brown wrote: > On Tue, Jan 11, 2011 at 22:35, David McGlone wrote: > > Hi Everyone, I'm having a problem validating some links I have in a > > foreach. Here is my code: > > > "http://www.w3.org/TR/html4/loose.dtd";> > > > > my PHP code: > > $categorys = array('home', 'services', 'gallery', 'about_us', > > 'contact_us', 'testimonials'); > > foreach($categorys as $category){ > > $replace = str_replace("_", " ", $category); > > echo "$replace"; > > } > > > > Validator Error: > > an attribute value must be a literal unless it contains only name > > characters > > This is because you misspelled $categorys, where it should > actually be $categories. Goes to show ya, even Deaf people aren't perfect spellers. Still like your little joke? ;-) -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HTML errors
On Wednesday, January 12, 2011 04:14:42 am Pete Ford wrote: > On 12/01/11 03:35, David McGlone wrote: > > Hi Everyone, I'm having a problem validating some links I have in a > > foreach. > > > > Here is my code: > >> > > "http://www.w3.org/TR/html4/loose.dtd";> > > > > my PHP code: > > $categorys = array('home', 'services', 'gallery', 'about_us', > > 'contact_us', 'testimonials'); > > foreach($categorys as $category){ > > $replace = str_replace("_", " ", $category); > > echo "$replace"; > > } > > > > Validator Error: > > an attribute value must be a literal unless it contains only name > > characters > > > > …ome>home > href=index.php?page=services>services > > > I have tried various combinatons and different doctypes. I'm beginning to > > wonder if this code is allowed at all. > > All the other replies are talking nonsense (especially Daniel ;) ! > There's no reason why HTML with single-quoted attributes isn't valid, so in > principle your expected output of > > services > > should be OK. > > The real challenge is to understand why the code fragment you have > presented is losing the single quotes: are you *sure* this is exactly what > you have in your file (i.e. have you copied it to the posted message > properly) ? Thanks Pete. Funny story. Ya'll better not laugh, especially you Denial, oops I mean Daniel ;-) Anyway, All of us would never have fixed this error. We could have added double quotes, single quotes and every combination even the worlds best programmer would use and it wouldn't have gotten us anywhere. Thats because if your working on the wrong file. :-) -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTML errors
On 12/01/11 03:35, David McGlone wrote: Hi Everyone, I'm having a problem validating some links I have in a foreach. Here is my code: http://www.w3.org/TR/html4/loose.dtd";> my PHP code: $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', 'testimonials'); foreach($categorys as $category){ $replace = str_replace("_", " ", $category); echo "$replace"; } Validator Error: an attribute value must be a literal unless it contains only name characters …ome>homeservices All the other replies are talking nonsense (especially Daniel ;) ! There's no reason why HTML with single-quoted attributes isn't valid, so in principle your expected output of services should be OK. The real challenge is to understand why the code fragment you have presented is losing the single quotes: are you *sure* this is exactly what you have in your file (i.e. have you copied it to the posted message properly) ? -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php