“最经常用作回调函数(callback)参数的值 ”这句话,老师讲的可不明白呀。伙伴们再读一下题意。老师的例子中是把匿名函数作为回调函数来用的。而不是回调函数参数的值。有没有伙伴可以贡献一下正解。
2018-01-29
case 3:
for ($i=1;$i<=$length;$i++){
if($i==rand(1,$length)||$i%2==0){
echo chr(rand(97,122)).'-';
}else
echo rand(0,9).'-';
}
break;
}
}
for ($i=1;$i<=$length;$i++){
if($i==rand(1,$length)||$i%2==0){
echo chr(rand(97,122)).'-';
}else
echo rand(0,9).'-';
}
break;
}
}
2018-01-28
function randTest($type,$length=4){
switch ($type){
case 1:
for($i=1;$i<=$length;$i++){
echo rand(0,9).'-';
}break;
case 2:
for($i=1;$i<=$length;$i++){
echo chr(rand(97,122)).'-';
}break;
switch ($type){
case 1:
for($i=1;$i<=$length;$i++){
echo rand(0,9).'-';
}break;
case 2:
for($i=1;$i<=$length;$i++){
echo chr(rand(97,122)).'-';
}break;
2018-01-28
function createFile($filename){
$file = $filename;
$a = substr(strrchr($file, '.'), 1);
return $a;
}
echo createFile('1.html');
$file = $filename;
$a = substr(strrchr($file, '.'), 1);
return $a;
}
echo createFile('1.html');
2018-01-25
function get_extension($file)
{
return pathinfo($file, PATHINFO_EXTENSION);//返回文件扩展名函数
}
{
return pathinfo($file, PATHINFO_EXTENSION);//返回文件扩展名函数
}
2018-01-17
// 查找文件名,输出后缀名
function extend_end($filename){
echo substr($filename, strripos($filename, '.'));
}
extend_end('hell000o .world.html');
function extend_end($filename){
echo substr($filename, strripos($filename, '.'));
}
extend_end('hell000o .world.html');
2017-12-23
任务:
function getFileExt(string $path) :string {
return pathinfo($path)['extension'];
}
function getFileExt(string $path) :string {
return pathinfo($path)['extension'];
}
2017-12-22
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}
}
echo get_extension('1234234.php.txt');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}
}
echo get_extension('1234234.php.txt');
?>
2017-12-20
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
$info = pathinfo($file);
return $info['extension'];
}
}
echo get_extension('1234234.php.txt');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
$info = pathinfo($file);
return $info['extension'];
}
}
echo get_extension('1234234.php.txt');
?>
2017-12-20
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return end(explode('.', $file));
}
}
echo get_extension('1234234.php.txt');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return end(explode('.', $file));
}
}
echo get_extension('1234234.php.txt');
?>
2017-12-20
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return substr($file, strrpos($file, '.')+1);
}
}
echo get_extension('1.php.html');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return substr($file, strrpos($file, '.')+1);
}
}
echo get_extension('1.php.html');
?>
2017-12-20