Live data from Hacker News

PHP Hacking aka trying to push PHP internals forwards

xarg.org

11–20 of 62 posts

Re: PHP Hacking aka trying to push PHP internals forwards

#11

Boo, deleted short tags. Why do people hate short tags again? I can't remember because <? is not valid XML so there shouldn't be any problems with mixing php and xml... hmm... I wonder ....

http://www.javacommerce.com/displaypage.jsp?name=pi.sql&...

So when someone uses more boilerplate to avoid conflict with 0.02% of the use cases where there's a problem is something to be proud of.

Re: PHP Hacking aka trying to push PHP internals forwards

#12

Earlier quoted context omitted.

It is not a unique escape code. Everytime I type those three little characters, it gives me great pleasure.

Can you give a demonstration of its non-uniqueness?

OTOH, you shouldn't ever be generating XML headers from PHP anyway (XHTML is a dead-end, and raw XML should be generated by an XML library), so this shouldn't be that big of an issue.

Re: PHP Hacking aka trying to push PHP internals forwards

#13

Earlier quoted context omitted.

Can you give a demonstration of its non-uniqueness?

OTOH, you shouldn't ever be generating XML headers from PHP anyway (XHTML is a dead-end, and raw XML should be generated by an XML library), so this shouldn't be that big of an issue.

But, less than question mark and a space are not a valid XML combination. XML processing instructions cannot begin with a space. Likewise, PHP cannot run commands into the short tags, like . So, there really is no collision, it's just grandstanding.

Re: PHP Hacking aka trying to push PHP internals forwards

#14

Earlier quoted context omitted.

OTOH, you shouldn't ever be generating XML headers from PHP anyway (XHTML is a dead-end, and raw XML should be generated by an XML library), so this shouldn't be that big of an issue.

But, less than question mark and a space are not a valid XML combination. XML processing instructions cannot begin with a space. Likewise, PHP cannot run commands into the short tags, like . So, there really is no collision, it's just grandstanding.

I wonder if the XML PI spec says anything about <?= Can you have a PI start with = ? If not, the echo short tag should stay for certain.

Re: PHP Hacking aka trying to push PHP internals forwards

#15

Boo, deleted short tags. Why do people hate short tags again? I can't remember because <? is not valid XML so there shouldn't be any problems with mixing php and xml... hmm... I wonder ....

Agreed... I've never used <? in a non-PHP context and it's way easier to type than <?php all the time. Why not just leave it in, or at least change it to something just as short but unique?

Re: PHP Hacking aka trying to push PHP internals forwards

#16
I was hoping for more profound changes. I've never read PHP internals but I'm under the impression the opcode language is not 'jitable' because it's an unformal mess while even python and lua are getting there ... It seems that Opcode caching is the most you can get out of the language as is.

Re: PHP Hacking aka trying to push PHP internals forwards

#17

Boo, deleted short tags. Why do people hate short tags again? I can't remember because <? is not valid XML so there shouldn't be any problems with mixing php and xml... hmm... I wonder ....

<?= always exists as of PHP 5.4, despite the short tags setting.

Re: PHP Hacking aka trying to push PHP internals forwards

#18

Boo, deleted short tags. Why do people hate short tags again? I can't remember because <? is not valid XML so there shouldn't be any problems with mixing php and xml... hmm... I wonder ....

<?= always exists as of PHP 5.4, despite the short tags setting.

Yay

Re: PHP Hacking aka trying to push PHP internals forwards

#19

Good to see. It's about time PHP got forked even if experimentally. It seems to me that you could fix a lot of the problems with PHP by breaking backwards compatibility.

What would a sane version of PHP look like? What are the good parts of PHP besides easy setup?

Re: PHP Hacking aka trying to push PHP internals forwards

#20

Good to see. It's about time PHP got forked even if experimentally. It seems to me that you could fix a lot of the problems with PHP by breaking backwards compatibility.

Many of the problems and annoyances with PHP could be fixed while keeping backwards compatibility.

Just a short list I can think of now:

- Short array syntax. Completely optional but would clean up the language quite a bit. This has been proposed several times and shot down each for no real good reason.

- Promote complex primitives into objects. With the proper interfaces it wouldn't break any old code. Once this is done, deprecate the myriad of str* and array* functions in favor of the object methods. This also cleans up the "what order do i pass in the args" problem that so many people cite.

- Named parameters. Gets rid of passing in default params or an array blob for functions/methods that take lots of optional params. It also opens up the way for DSLs.

- Replace PEAR with something better. The quality of PEAR modules is really low and PEAR always seems to be broken one way or another.

- Add a list and hash type. PHP's array is very slow for some cases, and sometimes you need to enforce the datatype you're working with.

- Use exceptions for errors. Could be a runtime flag to prevent breaking things. It's incredibly easy to write bad code because PHP make it easy to ignore problems. Things like functions that connect to the db or trying to retrieve data from a stream don't throw exceptions on error.

Post reply on HN