dqeznd1697 2018-09-27 11:33
浏览 168
已采纳

如何获取所有参数(参数)及其各自的值,包括PHP中内置函数的可选参数(如果有的话)?

I'm using PHP 7.2.10

I am using a built-in PHP function htmlspecialchars()

Following is my code :

<?php
  $new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
  echo $new;
?>

I want to pass all the parameters(arguments) of the function htmlspecialchars() in above code. The expected parameter list should include all the parameters including the invisible parameters(i.e. default parameters) with their respective values as mentioned here

Thank You.

  • 写回答

1条回答 默认 最新

  • dounai9294 2018-09-27 11:46
    关注

    In short: no.

    ReflectionFunction::getParameters and ReflectionParameter::getDefaultValue should theoretically help here, but they don't work for built-in functions.

    var_dump(array_map(function ($p) { return $p->getDefaultValue(); }, 
                       (new ReflectionFunction('htmlspecialchars'))->getParameters()));
    

    So, no. Read the manual, see what the default values are, and hardcode them in your code. Or just don't pass them at all, since that's pointless.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料