2 PHP Versions: Classic and Pro

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

ole wrote:
The only reason i can imagine would be aesthetics, and that doesn't seem like a good criterium.
Don't replace it with anything. Why do we need a dollar in front of every variable? It seems to make the whole language a lot more symbolic and harder to read (not to mention type).
I can't imagine a PHP without the dollar sign. That's how the language works...

Here's an example that would be tricky (or undefined) to understand without the leading $ for a variable name:

Code: Select all

echo = "hello";
echo "john";
echo echo;
ole wrote: No a good version and a backwards compatible legacy version that would, yes, ultimately die out.
But with PHP4 and PHP5 and (not very) soon PHP6 we already know that the legacy version doesn't die out...
ole wrote:
How would you define 'more serious developers'?
And what would their needs be?
People who use PHP for a living and need a more structured and standardized language.
I know many 'more serious developers' (== people who use php for a living) that can live perfectly with php the way it is now.
ole wrote:
Why would we have to change PHP to suit their needs?Since they're more serious developers, can't they make it theirselves instead of harassing us with it?
Because of the flaws I've outlined.
In my experience, most of the 'more serious developers' wishes are ignored by the php-core team.. The only logical action would be that those 'more serious developers' make their own language and use that instead... I'm sorry, but i don't really see which flaws you've outlined that would stop 'more serious developers' from making this language.
ole wrote: And I'm not harassing anyone this is just a discussion. If you feel harassed unsubscribe from the thread.
I was talking about the 'more serious developers' you mentionned. No need to take this personal.

ole wrote:
since the default content-type for php is text/html i would expect the default output for echo/print calls to use htmlentities.
Errr...so you wouldn't actually be able to output any HTML just HTML entities?!
It would be possible to output html without htmlentities.. All html in a file (outside php parsing mode) can be outputted as is. And if one would need to output something as html, he would have to use an extra parameter echo($msg, $htmlentities = true)...
This way one would have to explicitely confirm that his data is ready for use as html...

(And as i wrote, i'm still considering if this would be a good thing)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I can't imagine a PHP without the dollar sign. That's how the language works...

Here's an example that would be tricky (or undefined) to understand without the leading $ for a variable name:

Code: Select all

echo = "hello";
echo "john";
echo echo;
OK. I accept your argument. In order for a dollarless PHP to work it would need to have stricter scope than it does and loads of variable names would still be off limits because of PHP keywords and functions. Thank you for showing me the purpose of the dollar variable syntax.
But with PHP4 and PHP5 and (not very) soon PHP6 we already know that the legacy version doesn't die out...
It will. PHP4 won't be the mainstream it is today in 10 years time. Over long enough timescales everything dies except maybe god but that is a whole other debate :P
I know many 'more serious developers' (== people who use php for a living) that can live perfectly with php the way it is now.
I use PHP for a living and I can live with PHP the way it is now. PHP is a great language but at the same time is far from perfect. I just started this thread for a bit of fun to gage how others feel about PHP and to try and identify what it is that stands between PHP today and a perfect PHP. Actually Perfect PHP is really just a pipe dream but you can have fun thinking about it.
In my experience, most of the 'more serious developers' wishes are ignored by the php-core team..
Really? Then what is all that expensive Zend software about then? The PHP-core team certainly appreicate the importance of keeping PHP easy but I don't think they ignore serious developers.
The only logical action would be that those 'more serious developers' make their own language and use that instead... I'm sorry, but i don't really see which flaws you've outlined that would stop 'more serious developers' from making this language.
Another language is always the solution. But how would it be different?
I was talking about the 'more serious developers' you mentionned. No need to take this personal.
I'm not offended, I started this thread for opinions. I'm just trying to tell you that I'm not starting this threa because I'm sick of PHP. I love PHP, I'm just interested in what would make it better.
It would be possible to output html without htmlentities.. All html in a file (outside php parsing mode) can be outputted as is. And if one would need to output something as html, he would have to use an extra parameter echo($msg, $htmlentities = true)...
This way one would have to explicitely confirm that his data is ready for use as html...

(And as i wrote, i'm still considering if this would be a good thing)
Well I'm very against that idea. It certainly doesn't simplify anything.
Do you really mean that you would find the following easy to remember?

Echo // echo with first character uppercase
echo // echo with all chars in lowercase
ECHO // echo with all chars in uppercase
That is an interesting suggestion. I certainly think this would be easier to remember than funny function names strtoupper, strtolower, ucfirst etc. But it would be VERY inconsistent with the rest of the language and not readable to those unfamiliar with the langauge so I would say no to that.

I like the idea of case sensitive functions because it forces everyone to write them in the same fashion. when you see STRLEN and strlen and strLen you know they are all the same function but that recognition takes a little bit more mental processing then if they were all written the same way. It also means you can use case based naming conventions like we already do with variables and constants. You can also force people into using niceVariableNotation too. I find alllowercasevariablenames quite tricky to read and all uppercase is no better.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

ole wrote: I use PHP for a living and I can live with PHP the way it is now. PHP is a great language but at the same time is far from perfect. I just started this thread for a bit of fun to gage how others feel about PHP and to try and identify what it is that stands between PHP today and a perfect PHP. Actually Perfect PHP is really just a pipe dream but you can have fun thinking about it.
I guess i'm too realistic to dream about a Perfect PHP ;)

I can get over the haystack/needle inconsistensies, but the lack of a 'uniform core' ( Virtually ever host has it's own set of installed extensions, php ini settings, allowed .htaccess settings, ...) is something that i experience as a serious limitation of developing with PHP.
ole wrote: The PHP-core team certainly appreicate the importance of keeping PHP easy but I don't think they ignore serious developers.
Admitted, they do appreciate user suggestions..
ole wrote:
It would be possible to output html without htmlentities..
Well I'm very against that idea. It certainly doesn't simplify anything.
It would prevent (not simplify) unknowing people from outputting potentially unsecure html code.. On the other hand, it would still allow one to output the data exactly the way he wants it (Unlike the magic_* stuff)

Even when everyone blindfully a FALSE parameter to their output function it would be *their* responsibility.. And noone could blame PHP for being unsecure by default...
ole wrote: I like the idea of case sensitive functions because it forces everyone to write them in the same fashion. when you see STRLEN and strlen and strLen you know they are all the same function but that recognition takes a little bit more mental processing then if they were all written the same way.
I agree that it's easier to read code that is written in a consistent fashion.
However i still feel that when STRLEN, strLEn, StrlEn, .. all can be different things it will take longer to understand what the code is doing...
ole wrote: It also means you can use case based naming conventions like we already do with variables and constants.
As you said yourself, there's nothing that stops you from doing it right now..

Thus, without the differentiation you can write things in a consistent fashion and you don't have to spend time figuring out the subtle differences between STRLEn and STRLeN. Why on earth would we want to change this? ;)
ole wrote: You can also force people into using niceVariableNotation too. I find alllowercasevariablenames quite tricky to read and all uppercase is no better.
Actually they can still name their variables how they want (as long as they meet the requirements: start with a dollar sign, ...)

I do appreciate code that is written in a consistent way (camelcasing/microsoftcasing member functions, uppercase for constants, indentation, ...) but i just fail to see what the case-sensitivity has to offer...
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

As you said yourself, there's nothing that stops you from doing it right now..

Thus, without the differentiation you can write things in a consistent fashion and you don't have to spend time figuring out the subtle differences between STRLEn and STRLeN. Why on earth would we want to change this? Wink
Well you can't do it with function names which is my point.

How about this:
You are allowed to name functions and variables with any case. When you come to use them you have to use the case as it was declared. You cannot declare another function or variable that case-insensitively matches an existing one.

I think that's a good compromise.
Post Reply