社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Jujhar Singh

Jujhar Singh 最近创建的主题
Jujhar Singh 最近回复了
13 年前
回复了 Jujhar Singh 创建的主题 » php python样式的函数变量[重复]

简单的回答。不,你不能。
您可以尝试通过传入对象/数组或使用其他依赖注入模式来绕过它。

此外,尝试使用空值而不是空字符串,因为使用iSnull()测试它们的存在更为明确。

如:

function test ($a=null,$b=null,$c=null){
 if (is_null($a) {
  //do something about $a
 }
 if (is_null($b) {
  //do something about $b
 }
 if (is_null($c) {
  //do something about $c
 }
}

叫这个:

test(null,null,"Hello");