Chrome Extension

String interpolation and formation in PHP

We can easily format strings with variables in PHP. In the code snippet, we are formatting our string using variable name and using curly brackets.
    $name = "world";
    echo "Hello $name";
    //-> Hello World

    $arr = [
        'name' => 'John'  
    echo "My Name is '{$arr["name"]}'";
    //-> My Name is 'John'
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Was this helpful?