Manejo de variables
Tipo string
";
echo "\$stringApostrofes = $stringApostrofes
";
echo "\$stringHeredoc = $stringHeredoc
";
echo "\$stringComillasAnidadas = $stringComillasAnidadas
";
echo "\$stringApostrofesAnidadas = $stringApostrofesAnidadas
";
echo "\$stringRutaTipoDOS = $stringRutaTipoDOS
";
echo "is_string()
";
$stringFalso = 10;
$stringValido = "texto";
if (is_string($stringFalso))
{
echo "\$stringFalso es string !
";
}
if (is_string($stringValido))
{
echo "\$stringValido es string !
";
}
echo "
";
// Comparar strings
$string1 = "xyz";
$string2 = "xYz";
$comparacion = strcmp($string1,$string2);
if ($comparacion < 0)
echo "\$comparacion = $comparacion - $string1 es menor a $string2";
elseif ($comparacion > 0)
echo "\$comparacion = $comparacion - $string1 es mayor a $string2";
else
echo "\$comparacion = $comparacion - $string1 es igual a $string2";
echo "
";
$string1 = "xyz1";
$string2 = "xyz";
$comparacion = strcasecmp($string1,$string2);
if ($comparacion < 0)
echo "\$comparacion = $comparacion - $string1 es menor a $string2";
elseif ($comparacion > 0)
echo "\$comparacion = $comparacion - $string1 es mayor a $string2";
else
echo "\$comparacion = $comparacion - $string1 es igual a $string2";
echo "
";
$valor1 = 10;
$valor2 = "10";
if($valor1 == $valor2) // Si cumple
echo "Son iguales
";
if($valor1 === $valor2) // No cumple
echo "Son identicos
";
echo "$valor1 = $valor2 : " . strcmp($valor1,$valor2) . "
";
$valor3 = 1;
$valor4 = "01";
if($valor3 == $valor4) // Si cumple
echo "Son iguales
";
if($valor3 === $valor4) // No cumple
echo "Son identicos
";
echo "$valor3 = $valor4 : " . strcmp($valor3,$valor4) . "
";
$valor5 = 1;
$valor6 = "1.0";
if($valor5 == $valor6) // Si cumple
echo "Son iguales
";
if($valor5 === $valor6) // No cumple
echo "Son identicos
";
echo "$valor5 = $valor6 : " . strcmp($valor5,$valor6) . "
";
$valor7 = "1.";
$valor8 = "01";
if($valor7 == $valor8) // Si cumple
echo "Son iguales
";
if($valor7 === $valor8) // No cumple
echo "Son identicos
";
echo "$valor7 = $valor8 : " . strcmp($valor7,$valor8) . "
";
$valor9 = 0;
$valor10 = "xyz";
if($valor9 == $valor10) // Si cumple
echo "Son iguales
";
if($valor9 === $valor10) // No cumple
echo "Son identicos
";
echo "$valor9 = $valor10 : " . strcmp($valor9,$valor10) . "
";
echo "
";
$texto1 = '\tTabulador\r\n\\Backslash\"\'';
$texto2 = '\tTabulador\r\n\\Backslash"\'';
$texto3 = "\tTabulador\r\n\\Backslash\"\'";
$texto4 = "\tTabulador\r\n\\Backslash\"'";
echo "$texto1
";
echo "$texto2
";
echo "$texto3
";
echo "$texto4
";
?>