Sunday, 18 April 2021

PHP string interporlation VS JS string interoprlation

 "" double quote in php is evaluate variable in string

<?php
$a = 'test';

echo "this is {$a}";  // this is test

'' single quote is scalar eveything is string , variable not evaulated

<?php

$a = 'test';


echo 'this is {$a}'; //this is {$a}

https://stackoverflow.com/questions/5605965/php-concatenate-or-directly-insert-variables-in-string

https://stackoverflow.com/questions/3304014/how-to-interpolate-variables-in-strings-in-javascript-without-concatenation
` ` means template literal, means everything in string treated as it is, works with multi line, variable are evaluated
`String text ${expression}`
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
var a = 5;
var b = 10;
console.log(`Fifteen is ${a + b}.`);
// "Fifteen is 15.

No comments:

Post a Comment