axy/evil 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

axy/evil

Composer 安装命令:

composer require axy/evil

包简介

Necessary evil

README 文档

README

Latest Stable Version Minimum PHP Version Build Status Coverage Status License

  • The library does not require any dependencies.
  • Tested on PHP 5.4+, PHP 7, HHVM (on Linux), PHP 5.5 (on Windows).
  • Install: composer require axy/evil.
  • License: MIT.

Documentation

Some language features are not recommended for frequent use. eval(), exit, global variables, direct access to super-global arrays.

But sometimes it is necessary. If you use static code analyzer, it will swear. We'll have to suppress messages.

/** @SuppressWarnings(PHPMD.Superglobals) */
$x = $_POST['x'];

This library encapsulates the "evil" features. You simply call methods and disclaims any sin.

API

Classes are in the namespace axy\evil.

Evil

It contains calls of "evil" functions. So how exit, echo and etc is keywords methods have other names.

eval - execCode
Evil::execCode('2 + 2'); // 4
exit - stop
Evil::stop(); // exit
Evil::stop(5); // exit with code 5
breakpoint()
breakpoint(mixed $message [, bool $line [, bool $file [, int $status]);

Shows debugging information and terminates the current script (with the status from $status).

If $message is not a scalar then used print_r().

If specified $line: shows the line number of the breakpoint. For $file shows the file name.

Evil::breakpoint('point'); // point
Evil::breakpoint('point', true); // 15: point
Evil::breakpoint('point', true, true); // /path/to/script.php:15: point

In CLI mode the $message completes new line. In HTTP mode the $message enclosed in <pre>.

echo - out
Evil::out($message);

Sends a string to the stdout stream.

Superglobals

Static methods of axy\evil\Superglobals:

  • getSERVER()
  • getGET()
  • getPOST()
  • getREQUEST()
  • getCOOKIE()
  • getFILES()
  • getSESSION()
  • getENV()

Return the corresponding superglobals arrays. The data is returned by reference.

$session = Superglobals::getSESSION();
$session['var'] = 'value'; // no effect

$session = &Supeglobals::getSESSION();
$session['var'] = 'value'; // success

Globals

Static methods:

  • getGLOBALS(): returns $_GLOBALS by reference
  • get($name [, $default]): returns the value of a global variable (or $default if the variable not found)
  • set($name, $value): set
  • remove($name): unset

统计信息

  • 总下载量: 435
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固