本文介绍了创建一个新的“命令".在PHP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到一些PHP应用程序使用如下代码行:
I've seen some PHP applications use lines of code that are like this:
throw new Exception(....);
我该如何做其中之一?我想做一些投掷"命令.那叫什么?
How do I make one of those? I want to make sort of 'throw' command. What is that called?
例如,我正在编写一个应用程序,并且希望使后端易于使用,因此我想在开发人员要设置环境变量时使用它:
For example, I'm writing an application, and I want to make the backend easy to use, so I want to use this when a developer wants to set an environment variable:
add environment("varname","value");
但是我不知道该怎么做.
But I have no idea how to make one of those.
推荐答案
throw
是内置在语言中.要执行您想要的操作,将需要修改PHP编译器或实现 DSL ,而这两者都不是简单的任务.
throw
is built into the language. Doing what you want would require either modifying the PHP compiler or implementing a DSL, neither of which are simple tasks.
这篇关于创建一个新的“命令".在PHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!