PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Written By
Views

PHP the difference between single and double quotes

PHP the difference between single and double quotes

I've been programming in PHP for nearly 10 years, and I would consider myself to be fairly competent with the language. It's funny that some of the simplest things that I would program in PHP I would just accept certain aspects instead of looking further into them. I am talking in particular about single and double quotes. You can use either of these to output lines of code to a browser. You can even use them interchangeably from line to line.

What's the difference between the two? Well, after going through a beginner PHP course I found out that using double quotes PHP will actually output and render PHP variables; whereas, a single quote will only print out the string without rendering PHP.

As an example, the following PHP code:

$name = 'World';
echo "Hello $name";

Will print out: Hello World

Whereas the following code:

$name = 'World';
echo 'Hello $name';

Will print out: Hello $name

It's funny that it took me that long to figure that out. I guess it was just one of those things I didn't pay attention to. Well, now I know :P

Comments (0)

loading comments