php - 将 null 转换为字符串

标签 php null isnull

是否可以使用 php 将 null 转换为 string

例如,

$string = null;

$string = "null";

最佳答案

在 PHP 7 中,您可以使用 Null coalescing operator ??

$string = $string ?? 'null';

关于php - 将 null 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9913447/

相关文章:

php - 使用 PHP 和 CIDR 计算 IP 范围

php - Docker 服务 php-fpm 容器之间的 cURL 导致 "Connection refused"

null - Java EE 6 SDK 卸载 'Could not find the required version of the Java(TM) 2 Runtime Environment'

Javascript Null 和 Empty 检查

MySQL与空值比较

php - 更改从数据库获取日期的格式

php - 拉维尔 : MYSQL check if child belongs to top level parent with one query

java - 我的 RMI 服务器中的对象为空

php - mysqli 准备好的语句,使用绑定(bind)参数插入 NULL

javascript - 当其他工作正常时 document.getElementById 返回 null