Skip to content

u/ealf

In this archive from Jun 2008 to May 2012

10
posts
36
comments
0
media
1.3k
score

For browsers that "silently" drop broken HTTPS resources from HTTP pages, so you can do this:

<img src=https://mydomain.com/blank.gif
    onload="location.href='https://mydomain.com/'"
    onerror="location.href='http://mydomain.com/buy-a-cert/'">
1 points

OK, I went and looked at the code. It works as I expected (the reason the old-style constructor doesn't work is that the class name no longer matches the method name because of the namespace prefix), but for a period from 2008-2010 there was a workaround in place to de-namespace the classname before the check; that workaround was reverted in r297482.

I love how they handled the test:

   --TEST--
-  063: Support for old-style constructors in namesapces
+  063: Old-style constructors in namesapces (not supported!)
   --FILE--
   <?php
   namespace Foo;
   class Bar {
    function Bar() {
            echo "ok\n";
    }
   }
   new Bar();
+  echo "ok\n";
   --EXPECT--
   ok
2 points

That may be so but this isn't a bug. If there was a language specification then we might be able to call it a bug. But PHP has no official language specification.

If there were a specification, we would be able to say whether the bug was in the specification or in the parser.

Since there is no specification, my only option is to to call it a parser bug. I certainly don't think it was intentional.

However we know it's written in C++ and is heavily influenced by it, so we can maybe look to C++ to see what's going on.

That might be a little misleading. PHP is written in C and the object system is much closer to Java than C++.

Traditionally the new operator allocates memory for the object and returns a reference to the uninstantiated object. Overload new in C++ to see this; you return a pointer to raw memory, not an object.

I think wvenable was talking about the new operator (which allocates, initializes and returns a new object); you're talking about what C++ calls operator new() (which controls only the first part).

Which is why with the way C++ evaluates expressions, you can't chain from new. But you can force evaluation after instantiation with parentheses, e.g. foo* x = (new foo())->bar();

The C++ equivalent of Java's new Foo().bar() wouldn't be new Foo()->bar() but Foo().bar(), which parses perfectly. After using new you own the pointer, so dropping it on the floor would be bad form.

3 points

I've been there. The machine said my laptop had explosives residue on it. It started beeping loudly and flashing "EXPLOSIVES" on its little screen.

The security people's response? Well, they cleared out the people behind me (to a blast radius of 20 feet or so), brought out The Form, filled it out, stamped it, and sent me on my way.

20 points

"We seem to have a compulsion these days to bury time capsules in order to give those people living in the next century or so some idea of what we are like. I have prepared one of my own. I have placed some rather large samples of dynamite, gunpowder, and nitroglycerin. My time capsule is set to go off in the year 3000. It will show them what we are really like."

5 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.