5 days later

NB: I got the "this thread is rather old" warning when I started to post.

TIL that Salads > Pizza for attention's sake, though pizza tastes much better. #Wait #AlreadyKnewThat #ZZZZ #CarbLoaded2pm....

    8 days later
    16 days later

    sneakyimp

    TIL (not really today, but it came up again today) that a nonbreaking space is a valid character that can be used in identifiers.

    <?php
    $fo = 42;
    $fo = 17;
    echo $fo ;

    Outputs 42 because of course that's $fo  in the first and third positions, but only $fo in the middle.

    And it's also valid in constants as well (strictly speaking, almost all strings are valid as constant names, but most of them can't be used without wrapping them in constant()):

    <?php
    define(' ', 42);
    function foo() { return ;}
    echo foo();

    Edit: Hey; still got the error message but the thread got bumped to the top of the list!

    Weedpacket TIL (not really today, but it came up again today) that a nonbreaking space is a valid character that can be used in identifiers.

    YUCK. I do not like this idea very much. Seems like it opens the door to security problems.

    TESTING #10
    Looks like the issue was fixed and the error has gone away and this and other thread move to the top as expected.

    EDIT: Or maybe not.:

      Yeah, the "last replied" didn't update either.

      On subject:
      Did You Know:
      PHP's "__construct" is just a well-known name for an ordinary instance method? The only special treatment it gets is the property promotion syntax and an exemption from type variance constraints.

      class Foo
      {
      	public function __construct(public int $prop)
      	{
      		return 'Hello, World!';
      	}
      }
      
      $k = new Foo(42);
      echo $k->prop, "\n";
      echo $k->__construct(17), "\n";
      echo $k->prop, "\n";

        sneakyimp YUCK. I do not like this idea very much. Seems like it opens the door to security problems.

        It's nothing new; this has always been the case with PHP. So if there is a security hazard (which requires bad actors having write access to source code) it's one that has always been there. It's no different from

        <?php
        $fo=42;
        $fο=17;
        echo $fo;

        except a little more fragile (because nonbreaking spaces don't copy-paste quite so reliably as omicrοn) and harder to spot if syntax highlighting doesn't assume all identifiers are in ASCII.

        TIL:

        
        function cmp($n, $m) { return $n - $m;}
        
        $el_gordo = 3*(PHP_INT_MAX >> 2);
        
        $data = [0, 1, 6, -42, 25, -1000, $el_gordo, -$el_gordo];
        
        usort($data, cmp(...));
        
        echo join(' ', $data);

        When passed $el_gordo and -$el_gordo, cmp returns a double (equivalent to (3/2)PHP_INT_MAX) instead of an integer. and usort doesn't like that. It won't complain, but it doesn't like that.

        20 days later

        shell>ls | grep PZCF
        PZCFBLSBL
        shell>mv PZCFBLSBL PZ/
        PZCFBLSBL: no such file
        shell>file PZCFBLSBL
        PZCFBLSBL: no such file
        dale>wget mad.jpeg
        ...
        shell> ls -Aqb | cat -v | grep PZCF
        M-0M-?PZCFBLSBL
        shell>mv *PZCFBLSBL* PZ/PZCFBLSBL
        dale>wget happy.jpeg

        😄

          3 months later

          TIL Goldman Sachs recently turned bearish on generative AI, citing overspending and lack of returns/benefit.

          Write a Reply...