Search
 
SCRIPT & CODE EXAMPLE
 

PHP

boolean to string php

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

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

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

string to boolean php

filter_var(    true, FILTER_VALIDATE_BOOLEAN); // true
filter_var(    'true', FILTER_VALIDATE_BOOLEAN); // true
filter_var(         1, FILTER_VALIDATE_BOOLEAN); // true
filter_var(       '1', FILTER_VALIDATE_BOOLEAN); // true
filter_var(      'on', FILTER_VALIDATE_BOOLEAN); // true
filter_var(     'yes', FILTER_VALIDATE_BOOLEAN); // true

filter_var(   false, FILTER_VALIDATE_BOOLEAN); // false
filter_var(   'false', FILTER_VALIDATE_BOOLEAN); // false
filter_var(         0, FILTER_VALIDATE_BOOLEAN); // false
filter_var(       '0', FILTER_VALIDATE_BOOLEAN); // false
filter_var(     'off', FILTER_VALIDATE_BOOLEAN); // false
filter_var(      'no', FILTER_VALIDATE_BOOLEAN); // false
filter_var('asdfasdf', FILTER_VALIDATE_BOOLEAN); // false
filter_var(        '', FILTER_VALIDATE_BOOLEAN); // false
filter_var(      null, FILTER_VALIDATE_BOOLEAN); // false
Comment

php boolean to string

$converted_res = $res ? 'true' : 'false';
Comment

PREVIOUS NEXT
Code Example
Php :: how to use join query in codeigniter 
Php :: htaccess cakephp 
Php :: last login date time in wordpress 
Php :: php model last record 
Php :: php find differences between two arrays 
Php :: php check if input is date 
Php :: log facade laravel 
Php :: check table exists in db laravel 
Php :: php yesterday 
Php :: how to remove token while logout using laravel 8 
Php :: twig jsoncencode 
Php :: laravel foreign key 
Php :: Carbon add 3 hours 
Php :: parsefloat php 
Php :: Your Composer dependencies require a PHP version "= 7.3.0" 
Php :: is php and javascript similar 
Php :: switch between php version ubuntu nginx 
Php :: php get start and end date of month and year 
Php :: array empty check in php 
Php :: laravel db transaction 
Php :: get category name by id wordpress 
Php :: how to define variable as object in blade laravel 
Php :: how to disable/hide menu admin page wordpress dev 
Php :: how to get array dont similer elements in php 
Php :: php regex remove characters from string 
Php :: laravel get query output 
Php :: datetime format laravel 
Php :: twig print_r 
Php :: php auto scoll page with output 
Php :: displaying laravel error in below input field 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =