您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

PHP:变量在函数内部不起作用?

PHP:变量在函数内部不起作用?

有几种方法可以解决此问题:

echo $path; // working

function createList($retval) {
  global $path;

  echo $path; // working

define(PATH, "/my/test/path"); // You can put this in an include file as well.

echo PATH; // working

function createList($retval) {

  echo PATH; // working

echo $path; // working

function createList($retval, $path) {

  echo $path; // working

根据功能的实际工作原理,其中之一会起作用。

php 2022/1/1 18:14:35 有505人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶