disabled
public static function toggleDisabled(array $pull) {
$path = storage_path('disabled.json');
$json = json_decode(file_get_contents($path), true);
if (!isset($json['disabled']))
return false;
if(in_array($pull, $json['disabled']))
array_push($json['disabled'], $pull);
else
unset($json['disabled'][array_search($pull, $json['disabled'])]);
file_put_contents($path, json_encode($json));
return true;
}
$escapedTextarea = htmlspecialchars($_GET['description']);
<?php
abstract class Controller {
function render(string $file, array $vars = []) {
foreach ($vars as $key => $value)
$$key = $value;
ob_start();
include $file;
return ob_get_clean();
}
}
class MainController extends Controller {
function index() {
return $this->render('hello.php', [
'title' => 'Hello',
'message' => 'Hello world!'
]);
}
}
<h1><?= $title ?></h1>
<p><?= $message ?></p>
<?php
class CallableClass
{
public function __invoke($x)
{
var_dump($x);
}
}
$obj = new CallableClass;
$obj(5);
var_dump(is_callable($obj));
?>