- preg_match: documentation ( source)
- strtr: documentation ( source)
- file_put_contents: documentation ( source)
<?php
$msg=$_GET['msg']??"no msg!";
file_put_contents('msg.log.txt',$msg."\r\n",FILE_APPEND|LOCK_EX);
$matches=NULL;
$isMatch=preg_match("/\d+\s*(?:\+|\-|\*|\/|\:)\s*\d+/",$msg,$matches);
if($isMatch){
$matches[0]=strtr($matches[0],array(':'=>'/'));
//var_dump($matches) & die();
$res=eval("return (".$matches[0].");");
// var_dump($res);
echo "!check {$res}";
}