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

  • By
    fetch API

    One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn't really made for what we've been using it for.  We've done well to create elegant APIs around XHR but we know we can do better.  Our effort to...

  • By
    5 Awesome New Mozilla Technologies You’ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...

Incredible Demos

  • By
    Control Element Outline Position with outline-offset

    I was recently working on a project which featured tables that were keyboard navigable so obviously using cell outlining via traditional tabIndex=0 and element outlines was a big part of allowing the user navigate quickly and intelligently. Unfortunately I ran into a Firefox 3.6 bug...

  • By
    Dynamically Load Stylesheets Using MooTools 1.2

    Theming has become a big part of the Web 2.0 revolution. Luckily, so too has a higher regard for semantics and CSS standards. If you build your pages using good XHTML code, changing a CSS file can make your website look completely different.

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!