Strings with single or double quotes [closed]

1

What is the difference between using single quotes or double quotes?

$tipoFile = "application/vnd.ms-excel";
$mimeFile = "text/plain";
$ruta = FILE_DIR . "/carga/";
$formato = 'CUOTAS'.$_SESSION['anio'].".csv";

Well, in the manual of php.net they use single and / or double quotes in many of their examples.

    
asked by Piropeator 20.11.2018 в 22:14
source

1 answer

1

Both single and double quotes are used to specify strings, the reference is that the single quote specifies strings literally and the double quotes specify strings with some conversions: variables by their value and escaped values.

    $mundo = 'pepe';

    echo 'hola $mundo';
    // hola $mundo

    echo "hola $mundo";
    // hola pepe

    echo "Realiza un salto de linea al final\n";
    echo 'No realiza salto de linea al final\n';

More information on the documentation.

Use them as appropriate; -)

    
answered by 20.11.2018 / 22:29
source