php-general Digest 12 Jan 2011 19:45:14 -0000 Issue 7129
Topics (messages 310689 through 310703):
Re: First PHP job
310689 by: Gary
Re: HTML errors
310690 by: Pete Ford
310691 by: David McGlone
310692 by: David McGlone
310693 by: Steve Staples
310694 by: Richard Quadling
310695 by: Daniel Brown
310696 by: Richard Quadling
310697 by: David McGlone
310698 by: Steve Staples
310699 by: Richard Quadling
310700 by: David Harkness
310701 by: Daniel Brown
310702 by: tedd
Array Symbol Suggestion
310703 by: sono-io.fannullone.us
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Peter Lind wrote:
> On Jan 11, 2011 4:32 PM, "Gary" wrote:
>>
>> Steve Staples wrote:
>> > or the ($needle, $haystack) vs ($haystack, $needle)... i still get
> it
>> > screwed up...
>>
>> Given that, for example, array_search and strstr take those arguments
> in
>> different orders, that's not really surprising.
>>
>
> Something tells me that's what he meant ...
I read it that he could never remember which order to put them in.
--- End Message ---
--- Begin Message ---
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:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"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 "<li><a href='index.php?page=$category'>$replace</a></li>";
}
Validator Error:
an attribute value must be a literal unless it contains only name characters
…ome>home</a></li><li><a href=index.php?page=services>services</a></li><li><a
h…
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
<a href='index.php?page=services'>services</a>
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 893333 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
--- End Message ---
--- Begin Message ---
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:
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> >
> > "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 "<li><a href='index.php?page=$category'>$replace</a></li>";
> > }
> >
> > Validator Error:
> > an attribute value must be a literal unless it contains only name
> > characters
> >
> > …ome>home</a></li><li><a
> > href=index.php?page=services>services</a></li><li><a h…
> >
> > 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
>
> <a href='index.php?page=services'>services</a>
>
> 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.
--- End Message ---
--- Begin Message ---
On Tuesday, January 11, 2011 11:48:33 pm Daniel Brown wrote:
> On Tue, Jan 11, 2011 at 22:35, David McGlone <[email protected]> wrote:
> > Hi Everyone, I'm having a problem validating some links I have in a
> > foreach. Here is my code:
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "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 "<li><a href='index.php?page=$category'>$replace</a></li>";
> > }
> >
> > 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.
--- End Message ---
--- Begin Message ---
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:
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "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 "<li><a href='index.php?page=$category'>$replace</a></li>";
>
> Try this instead
>
> echo '<li><a href="index.php?page=',$category,'">',$replace,'</a></li>';
>
> 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 "<li><a href=\"index.php?page={$category}\">{$replace}</a></li>";
Steve Staples.
--- End Message ---
--- Begin Message ---
On 12 January 2011 13:20, Steve Staples <[email protected]> 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 "<li><a href=\"index.php?page={$category}\">{$replace}</a></li>";
>
> 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
--- End Message ---
--- Begin Message ---
On Wed, Jan 12, 2011 at 06:38, David McGlone <[email protected]> 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.
--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/
--- End Message ---
--- Begin Message ---
On 12 January 2011 13:43, Daniel Brown <[email protected]> wrote:
> On Wed, Jan 12, 2011 at 06:38, David McGlone <[email protected]> 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
--- End Message ---
--- Begin Message ---
On Wednesday, January 12, 2011 08:43:35 am Daniel Brown wrote:
> On Wed, Jan 12, 2011 at 06:38, David McGlone <[email protected]> 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.
--- End Message ---
--- Begin Message ---
On Wed, 2011-01-12 at 13:40 +0000, Richard Quadling wrote:
> On 12 January 2011 13:20, Steve Staples <[email protected]> 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 "<li><a href=\"index.php?page={$category}\">{$replace}</a></li>";
> >
> > 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.
--- End Message ---
--- Begin Message ---
On 12 January 2011 14:07, Steve Staples <[email protected]> wrote:
> On Wed, 2011-01-12 at 13:40 +0000, Richard Quadling wrote:
>> On 12 January 2011 13:20, Steve Staples <[email protected]> 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 "<li><a href=\"index.php?page={$category}\">{$replace}</a></li>";
>> >
>> > 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
--- End Message ---
--- Begin Message ---
On Wed, Jan 12, 2011 at 6:04 AM, David McGlone <[email protected]> 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 <[email protected]> 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
--- End Message ---
--- Begin Message ---
On Wed, Jan 12, 2011 at 12:08, David Harkness <[email protected]> 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.
--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/
--- End Message ---
--- Begin Message ---
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:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"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 "<li><a href='index.php?page=$category'>$replace</a></li>";
}
Validator Error:
an attribute value must be a literal unless it contains only name characters
ome>home</a></li><li><a href=index.php?page=services>services</a></li><li><a
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 <li> (i.e., list) should start with
a "type of list" tag, such <ol> for ordered list
-- there are several different types (i.e., ol,
ul, dir, menu, dl dt dd).
Third, you might try this:
echo("<li><a href=\"index.php?page=$category\">$replace</a></li>");
The Validator might be objecting to the way you use ' instead of ".
HTH's
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
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
--- End Message ---