草庐IT

static-compilation

全部标签

未找到 PHP __halt_compiler

我正在使用PHP5.6运行本地服务器。我正在使用第三方库,该库使用函数__halt_compiler。达到此功能后,我收到以下错误。PHPFatalerror:Uncaughtexception'UnexpectedValueException'withmessage'internalcorruptionofphar'.(__HALT_COMPILER();notfound)我使用关键字phar和__halt_compiler进行的所有搜索都没有结果。以下是打印phpinfo()的一些细节。Phar:PHPArchivesupport=>enabledPharEXTversion=>2

php - 引用 const 变量时 $this 或 self 或 static 哪个最好?

我了解到static比self好,因为self进行后期静态绑定(bind)。但我想知道哪种方法最适合引用const变量。classBlack{constcolor='black';publicfunctionbyThis(){return$this::color;}publicfunctionbySelf(){returnself::color;}publicfunctionbyStatic(){returnstatic::color;}}我检查了所有三个getter都工作正常。哪个是最好的选择?(我使用的是PHP7.0) 最佳答案

php - static 关键字对常量有影响吗?

classA{constFOO=1;}classBextendsA{constFOO=5;functionfoo(){printself::FOO;printstatic::FOO;}}$b=newB;$b->foo();两种情况下都打印5。那么在常量上使用static与self没有区别吗? 最佳答案 在LateStaticBinding的上下文中有区别。考虑这段代码:bar();//15如果您运行这段代码,输出将是:15当引用self::FOO时,打印1的值(即使bar()是在类上调用的B,但是当使用static关键字时,后期静态

php - 助手类 : Static or non-static functions

按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。当创建一个包含从字符串中去除空格等方法的辅助类时,您是将这些方法创建为static函数还是非static函数?另外,如果静态方法要调用类中的另一个函数do_magic(),该函数应该如何定义为(静态还是非静态?)我们是否必须使用self::?classHelper{publicstaticstrip_whitespace(){//dosomemagicse

php - 错误 :should not be called statically, 假设 $this 来自不兼容的上下文。只在我的机器上

我的团队成员在Controller中静态编写了模型函数调用,例如:$data=ModelName::functionName($param);虽然它应该被动态调用,例如:$model=newModel();$data=$model->functionName($param);大多数情况下,所有调用都是静态进行的。该代码在服务器和除我之外的本地计算机上运行。如果不重写庞大的代码库,静态调用太多无法修复。我总是通过composer更新我的项目。我的php版本是5.4。有人可能知道这是关于什么的吗? 最佳答案 您可能在运行PHP时报告了E

php - 为什么 Eclipse 反对 `static::$var` ?

我在PHP类中有以下静态函数:staticfunction__callStatic($method,$args){$called=NULL;if(empty(static::$collection))static::slurp();if(method_exists(static::$objtype,$method)){foreach(static::$collectionas$obj){$called[]=call_user_func_array(array($obj,$method),$args);}}elseif(property_exists(static::$objtype,$

php - php 中的 static 行为异常,无法接受函数

此代码抛出解析错误,我不明白为什么。functiont(){return'g';}functionl(){static$b=t();return$b;}l();问题是,为什么? 最佳答案 引用手册:Note:Tryingtoassignvaluestothese[static]variableswhicharetheresultofexpressionswillcauseaparseerror.(我的重点)比较http://www.php.net/manual/en/language.variables.scope.php示例#7

php - 逻辑异常错误 : Passed array does not specify an existing static method

请问我的autoloader类/函数与spl_autoload_register有任何错误吗?感谢您的帮助。这是我的代码我得到了这个错误Fatalerror:Uncaughtexception'LogicException'withmessage'Passedarraydoesnotspecifyanexistingstaticmethod(class'core'notfound)'inC:\xampp\htdocs\test\system\core.php:14Stacktrace:#0C:\xampp\htdocs\test\system\core.php(14):spl_auto

java - 使用 java 9 时无法执行 maven-compiler-plugin :3. 6.1:testCompile

我知道有很多类似错误的问题。我会很感激,因为重复考虑到它只发生在Java9中。我确实安装了java9C:\_pocs\ws_j9\java9-http-client>java-versionjavaversion"9.0.1"Java(TM)SERuntimeEnvironment(build9.0.1+11)JavaHotSpot(TM)64-BitServerVM(build9.0.1+11,mixedmode)C:\_pocs\ws_j9\java9-http-client>echo%JAVA_HOME%C:\ProgramFiles\Java\jdk-9.0.1为了简化示例,如

java - 如何为 com.sun.tools.javac.Main.compile() 函数设置类路径?

我正在使用com.sun.tools.javac.Main.compile()函数在运行时从我的struts项目编译java文件。但是对于某些文件,他们需要一些特定的jar,例如axis2。我有jar,但如何将它们设置为类路径以在运行时编译java文件?我尝试使用System.setProperty("java.class.path","jardir");但编译失败。 最佳答案 以下使用com.sun.tools.javac.Main的代码对我有用:苹果.java//ThisclassispackagedinajarnamedMyJ