在GET中休息回声与回归

时间:2017-07-20 17:38:57

标签: php rest return-value

我是php和休息的新手,我在尝试使用public static function load($className) { if (!isset(static::$_classMap[$className])) { return false; } if (strpos($className, '..') !== false) { return false; } $parts = explode('.', static::$_classMap[$className], 2); list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); $file = static::_mapped($className, $plugin); if ($file) { return include $file; } $paths = static::path($package, $plugin); if (empty($plugin)) { $appLibs = empty(static::$_packages['Lib']) ? APPLIBS : current(static::$_packages['Lib']); $paths[] = $appLibs . $package . DS; $paths[] = APP . $package . DS; $paths[] = CAKE . $package . DS; } else { $pluginPath = CakePlugin::path($plugin); $paths[] = $pluginPath . 'Lib' . DS . $package . DS; $paths[] = $pluginPath . $package . DS; } $normalizedClassName = str_replace('\\', DS, $className); // Start point of custom codes // Load Custom Classes that are usually added during customizations // This part is for accepting a class like **XControllerCustom** but the name of file is: **XController** if($package === 'Model'){ foreach ($paths as $path) { $file = $path . DS . $className . '.php'; $file_custom = $path . 'Custom' . DS . $normalizedClassName . '.php'; if (file_exists($file_custom) && file_exists($file)) { self::_map($file_custom, $className); include $file; return include $file_custom; } } } // End of custom's code foreach ($paths as $path) { $file = $path . $normalizedClassName . '.php'; if (file_exists($file)) { static::_map($file, $className, $plugin); return include $file; } } return false; } vs biplot(*All of the parameters go in here*) title('This is a title.') xlabel('This labels the x-axis.') ylabel('This labels the y-axis.') 时试图了解我的API中发生了什么....

我试图找到最简单的方案来隔离我的其余API没有返回任何值的问题,所以这里是:

我的服务器上有一个echo文件,内容如下:

return

然后我使用一个简单的请求作为唯一标题' Content-Type:application / json`

test.php

结果分别是

<?php
    if(function_exists($_GET['t1'])) {
        echo $_GET['t1']();
    }
    else if(function_exists($_GET['t2'])) {
        return $_GET['t2']();
    }

    function test() {
        return json_encode("test...");
    }
?>

我真的很难理解这一点,为什么我的回报价值不知何故&#34;失去&#34; - 有什么解释吗?!

2 个答案:

答案 0 :(得分:1)

从函数返回实际上并不向响应呈现任何内容。您可能已经看到人们在不同的框架中返回数据,但框架实际上是在幕后回显数据。

答案 1 :(得分:0)

return为函数调用赋值(如变量),echo只输出到html页面或可能是终端窗口。

相关问题