“PHP booleano a la cadena” Código de respuesta

booleano a cadena php

echo json_encode(true);  // string "true"

echo json_encode(false); // string "false"

// null !== false
echo json_encode(null);  // string "null"
Abs zarzis

PHP Convertir la cadena a booleano

/**
 * Strings always evaluate to boolean true unless they have a
 * value that's considered "empty" by PHP (taken from the
 * documentation for empty):
 * "" (an empty string) evaluates as false.
 * "0" (0 as a string) evaulates as false.
 * If you need to set a boolean based on the text value of a
 * string, then you'll need to check for the presence or
 * otherwise of that value.
 */
$boolean = $string === 'true' ? true: false;
SmokeFrog

PHP booleano a la cadena

$converted_res = $res ? 'true' : 'false';
Concerned Chipmunk

PHP se convierte en booleano

// (PHP 5 >= 5.5.0, PHP 7)
// boolval — Get the boolean value of a variable
boolval ( mixed $var ) : bool
// Returns the boolean value of var.
P. Tune

Respuestas similares a “PHP booleano a la cadena”

Preguntas similares a “PHP booleano a la cadena”

Más respuestas relacionadas con “PHP booleano a la cadena” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código