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
    Facebook Open Graph META Tags

    It's no secret that Facebook has become a major traffic driver for all types of websites.  Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly.  And of course there are Facebook "Like" and "Recommend" widgets on every website.  One...

  • By
    Being a Dev Dad

    I get asked loads of questions every day but I'm always surprised that they're rarely questions about code or even tech -- many of the questions I get are more about non-dev stuff like what my office is like, what software I use, and oftentimes...

Incredible Demos

  • By
    9 Mind-Blowing Canvas Demos

    The <canvas> element has been a revelation for the visual experts among our ranks.  Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead.  Here are nine unbelievable canvas demos that...

  • By
    New MooTools Plugin:  ElementFilter

    My new MooTools plugin, ElementFilter, provides a great way for you to allow users to search through the text of any mix of elements. Simply provide a text input box and ElementFilter does the rest of the work. The XHTML I've used a list for this example...

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!