Odd Custom PHP Variables

By  on  

Creating custom-named PHP variables is pretty easy:

${'username'} = 'User1010'; // same as $username = 'User1010';

But did you know that you can create variables with spaces? The following will work:

${'name of user'} = 'David Walsh';
echo ${'name of user'};

I can't see any reason to do this, but it's possible.

Recent Features

Incredible Demos

  • By
    CSS Fixed Position Background Image

    Backgrounds have become an integral part of creating a web 2.0-esque website since gradients have become all the rage. If you think gradient backgrounds are too cliche, maybe a fixed position background would work for you? It does provide a neat inherent effect by...

  • By
    Introducing LazyLoad 2.0

    While improvements in browsers means more cool APIs for us to play with, it also means we need to maintain existing code.  With Firefox 4's release came news that my MooTools LazyLoad plugin was not intercepting image loading -- the images were loading regardless of...

Discussion

  1. Reminds me of a templating variable. Could possibly be used in the case of having non-programming html-designers making the pages.

    Hopefully someone else knows more about the benifits of this. :)

  2. I’m really not sure, but as I used flash and dynamic variable creation, this somehow looks familiar for me. It makes sence in flash, but I don’t know why I should do this in php. I mean, arrays are better that that, right?
    I dunno! Makes me wondering …

  3. echo ${‘name of user’};

    lol, thats useful innit? ;)

    Great site btw. cheers.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!