|
Posted by Tony Marston on 07/17/06 07:35
"Bent Stigsen" <ngap@thevoid.dk> wrote in message
news:4596685.lTRPzWk8YV@thevoid.dk...
> Jerry Stuckle wrote:
>> Bent Stigsen wrote:
> [snip]
>> True, I'm not using it in the C sense. But I'm not using "define" in
>> the Cobol sense, either :-). In PHP, assigning a value to a variable
>> defines it.
>
> That sortof went over my head. Never done Cobol. :)
> I didn't really consider the subtler differences. Not sure I understand
> PHP's way anyway. For instance:
>
> unset($a);
> $b = null;
>
> "isset" returns false for both $a and $b, even though key of 'b' is
> present
> in the $GLOBALS array.
> Use of $a will generate a notice, but not when using $b.
>
> I don't understand the point in that.
You can put a value into a variable without having to define the variable
beforehand. If you attempt to read from a variable that does not yet exist
then a ntice is generated. What's so difficult about that?
>
>> And it can't be used anyplace other then the left side of
>> an assignment operator (rvalue in C terms) until it is defined.
>
> Not sure I follow.
If it's on the left you are putting a value in, if it's on the right you are
trying to get a value out.
> I think it would depend on what the intention and
> situation. In vito's case, there shouldn't be a problem using it
> ($array[$i][1]) as an rvalue when undefined if just used to concatenate
> strings, as it will initially just appear as an empty string. Just
> suppressing the notice should work fine.
> I.e.: $array[$i][1] = @$array[$i][1] . $line;
>
> In other cases it, then sure it would be an error.
>
>
>> However, most C programmers aren't aware of the terms lvalue and rvalue,
>> either, or if they are, have only a hazy idea of what they mean.
>
> Would they not know? I believe the compiler will use the terms if one
> screws
> up, allthough perhaps one should be drunk to cause it.
>
>
> [snip]
>> Now in C/C++ I have done this. But these programs are typically much
>> more complex than PHP programs. For instance - I haven't seen too many
>> 500K LOC PHP programs. But I have worked on several over the years in
>> C/C++.
>
> Can be generated in seconds, no biggie :)
>
> awk 'BEGIN{print"<?php";for(i=0;i<ARGV[1];i++){printf"echo\"";
> n=int(35*(1+sin(i/10)));for(j=0;j<int(n/8);j++)printf"\t";
> for(j=0;j<n%8;j++)printf"\040";printf("%d\\n\";\n",i)}
> print"?>";}' 500001 > bigbadacode.php
>
> Bit of a memory-hog and pretty useless though, but it exceeds 500K.
>
>
>> My point being - PHP is a different language - and one should be
>> approaching PHP development differently than C/C++ development.
>
> For sure. My oppinion of PHP varies a lot. One day I would consider it a
> rotting stinking goat carcass which only dogs would take a roll in
> (figuratively speaking, no offense to dogs), find myself rolling in it the
> very next day, and cant stand the smell on the third day.
This tells me that you are either using he language incorrectly, or you are
a pretty poor programmer.
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
[Back to original message]
|