批改状态:合格
老师批语:
// 1. global 关键字$name = '老朱';function name(){global $name ;return $name;}echo name() . '<br>';// 2. 超全局数组: $GLOBALS['outer']$name = '老李';function hello(): string{return 'Hello, ' . $GLOBALS['name'];}echo Hello() . '<hr>';// 3. 函数表达式: function () use ($outer){...}$name = '老陈';function () use ($name) :string{return 'Hello, ' . $name;};echo hello() . '<hr>';// 4. 箭头函数: fn()=>(...)$name = '老孙';$hello = fn() => 'Hello, ' . $name;echo hello(), '<hr>';// 5. 纯函数: function($outer){...}$name = '老林';$hello = function($name){return 'Hello, ' . $name;};echo hello($name), '<hr>';
// ucfirst:将首个字幕转换成大写$str = 'hello, world';echo ucfirst($str);echo '<hr>';// ucwords: 将字符串仲每个单词的首字符转换为大写$str = 'hello, world';echo ucwords($str);echo '<hr>';// lcfirst: 把字符串中首字符转化为小写$str = 'Hello, world';echo lcfirst($str);echo '<hr>';// strtoupper: 把字符串转换为大写$str = 'hello, world';echo strtoupper($str);echo '<hr>';// strtolower: 把字符串转换位小写$str = 'HELLO, WORLD';echo strtolower($str);echo '<hr>';
// 1. global 关键字$name = '老朱';function name(){global $name ;return $name;}echo name() . '<br>';// 2. 超全局数组: $GLOBALS['outer']$name = '老李';function hello(): string{return 'Hello, ' . $GLOBALS['name'];}echo Hello() . '<hr>';// 3. 函数表达式: function () use ($outer){...}$name = '老陈';function () use ($name) :string{return 'Hello, ' . $name;};echo hello() . '<hr>';// 4. 箭头函数: fn()=>(...)$name = '老孙';$hello = fn() => 'Hello, ' . $name;echo hello(), '<hr>';// 5. 纯函数: function($outer){...}$name = '老林';$hello = function($name){return 'Hello, ' . $name;};echo hello($name), '<hr>';
// ucfirst:将首个字幕转换成大写$str = 'hello, world';echo ucfirst($str);echo '<hr>';// ucwords: 将字符串仲每个单词的首字符转换为大写$str = 'hello, world';echo ucwords($str);echo '<hr>';// lcfirst: 把字符串中首字符转化为小写$str = 'Hello, world';echo lcfirst($str);echo '<hr>';// strtoupper: 把字符串转换为大写$str = 'hello, world';echo strtoupper($str);echo '<hr>';// strtolower: 把字符串转换位小写$str = 'HELLO, WORLD';echo strtolower($str);echo '<hr>';
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号