首页 \ 问答 \ php shell_exec()vs exec()(PHP shell_exec() vs exec())

php shell_exec()vs exec()(PHP shell_exec() vs exec())

我很难理解shell_exec()exec()之间的区别...

我一直使用exec()来执行服务器端命令,何时使用shell_exec()

shell_exec()exec()的缩写吗? 它似乎是同样的事情与较少的参数。


I'm struggling to understand the difference between shell_exec() and exec()...

I've always used exec() to execute server side commands, when would I use shell_exec()?

Is shell_exec() just a shorthand for exec()? It seems to be the same thing with fewer parameters.


原文:https://stackoverflow.com/questions/7093860
更新时间:2022-07-31 14:07

最满意答案

这取决于正则表达式引擎的实现。 假设没有什么真正的尴尬发生(例如,在这个正则表达式中不应该有回溯函数),我会说你的表达式产生的DFA会接受/拒绝O(n)中的任何字符串。

以下是Regexper表达式的描述:

在此处输入图像描述

请注意,没有办法说明一般正则表达式的复杂性。 一些正则表达式需要回溯,你可以制作指数时间匹配的表达式。 所以我的答案适用于这个特定的表达式,这个特定的表达式(实际上是任何特定的表达式)被编译成O(1)中的DFA。


That depends on the implementation of the regex engine. Assuming that nothing really awkward happens (there should be no backtracking involed in this regexp for example), I would say that the DFA resulting from your expression would accept/reject any string in O(n).

Here's a depiction of the expression from Regexper:

enter image description here

Note that there's no way to say what the complexity is for a general regexp. Some regexps require backtracking and you can craft expressions which take exponential time to match. So my answer applies to this particular expression, and this particular expression (any particular expression actually) is compiled into a DFA in O(1).

相关问答

更多
  • 看起来GWT不支持普通的Java正则表达式 (即不支持Pattern , Matcher和使用它的类/方法。 但是,有一个RegExp类可以提供这些功能。 It looks like GWT doesn't support normal Java regular expressions (i.e. doesn't support Pattern, Matcher and classes/methods that use it. There is a RegExp class that provides th ...
  • 一种简单的方法是使用Pattern类而不是仅使用matches()方法。 例如: Pattern ptn = Pattern.compile("[a-z]+", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); Matcher mtcher = ptn.matcher(myStr) .... An easy way is to use Pattern class instead of just using the matches() method. For ex ...
  • 尝试使用此表达式: [a-zA-Z]* (将匹配零个或多个字符)。 如果您需要至少一个字符,请使用: [a-zA-Z]+ 您使用的表达式只匹配单个字母字符,因为它没有量化 。 Try using this expression: [a-zA-Z]* (will match zero or more characters). If you require at least one character, use: [a-zA-Z]+ The expression you're using will only m ...
  • 这取决于正则表达式引擎的实现。 假设没有什么真正的尴尬发生(例如,在这个正则表达式中不应该有回溯函数),我会说你的表达式产生的DFA会接受/拒绝O(n)中的任何字符串。 以下是Regexper表达式的描述: 请注意,没有办法说明一般正则表达式的复杂性。 一些正则表达式需要回溯,你可以制作指数时间匹配的表达式。 所以我的答案适用于这个特定的表达式,这个特定的表达式(实际上是任何特定的表达式)被编译成O(1)中的DFA。 That depends on the implementation of the reg ...
  • String.matches(String)方法期望正则表达式作为参数。 它会检查你的str1是否与给定的正则表达式匹配。 您可能希望使用String.equals(Object)方法。 它检查两个字符串的内容是否相等。 The String.matches(String) method expects a regex as argument. It checks if your str1 matches the given regex. You probably want to use the Strin ...
  • [ ]*[0-9]+[ ]+[a-zA-Z]+[ ]+[a-zA-Z]+[ ]+[a-zA-Z]+[ ]?[a-zA-Z]*[ ]?[a-zA-Z]*[ ]?[a-zA-Z]*[ ^ ]?[a-zA-Z]*[ ]?[a-zA-Z]*[ ]?[0-9]+[ ]+[0-9]+[ ]+[0-9:.]+[ ]+ ^ ^ 你的正则表达式不允许0在整数。这就是为什么它失败。请参阅这里。 http://regex101.co ...
  • 好的,到目前为止,我还没有遇到过这个问题。 对于其他碰巧遇到这个问题的人,我只能建议你清理你正在工作的环境。这必须对损坏的JVM或计算机的内存状态进行一些处理。 感谢大家的贡献。 OK, so far I haven't encountered this issue anymore. For other who happen to meet this one someday, I can only suggest to clean up the environment that you are workin ...
  • 如果可以使用having(on(...))构造来实现,则调用可能如下所示: select(collection, having( on(String.class).matches("f*") )) 但不幸的是,这是不可能的,因为String类是final,所以on(String.class)无法创建having匹配器所需的代理。 虽然hamcrest没有带正则表达式匹配器 ,但您不必自己编写。 网提供了几种实现方式。 我想在一个即用型公共库中看到这样一个匹配器,我可以简单地将其作为依赖项包含在内,而不必复 ...
  • 您正在使用String.matches ,它将匹配整个String 。 试试这个: // | start of input // || "0" // ||| any character, 0 or more instances boolean startzero = r ...
  • 你寻找像这样的东西: String regex = "^[A-Za-z]+ [0-9]+$"; 说明: ^ the beginning of the string (nothing before the next token) [A-Za-z]+ at least one, but maybe more alphabetic chars (case insensitive) a single space (hard to see :) ) [0-9]+ at le ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。