php – 函数外部的变量中不允许表达式
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 函数外部的变量中不允许表达式,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1953字,纯文字阅读大概需要3分钟。
内容图文
![php – 函数外部的变量中不允许表达式](/upload/InfoBanner/zyjiaocheng/795/66d8a05694104da9a8da605f47b9189f.jpg)
我想将目录链接到$screenshotPath字符串,但PHPStorm中出现错误:表达式不允许作为字段默认值.我该如何解决?码:
use PHPUnit\Extensions\SeleniumTestCase;
use ApplicationTest\Bootstrap;
class AdminLoginLogoutTest extends PHPUnit_Extensions_SeleniumTestCase {
protected $captureScreenshotOnFailure = true;
//$screenshotPath is giving me this error...
protected $screenshotPath = __DIR__ . "/FailedTestsScreenshots";
protected $screenshotUrl = "http://icho/screenshots";
protected $path = "http://icho";
protected function SetUp() {
$this->setBrowser( "*firefox" );
$this->SetBrowserUrl( $this->path );
}
public function testAdminLoginLogout() {
$this->open( "/admin" );
$this->type( "name=username", "test" );
$this->type( "name=password", "test" );
$this->click( "id=submitbutton" );
$this->waitForPageToLoad( "30000" );
$this->assertEquals( "Dashboard", $this->getText( "link=Dashboard" ) );
$this->assertEquals( "Haios", $this->getText( "link=Haios" ) );
$this->assertEquals( "POs", $this->getText( "link=POs" ) );
$this->assertEquals( "Staco's", $this->getText( "link=Staco's" ) );
$this->assertEquals( "Mail templates", $this->getText( "link=Mail templates" ) );
$this->assertEquals( "Mailings", $this->getText( "link=Mailings" ) );
$this->assertEquals( "Sytem texts", $this->getText( "link=System texts" ) );
$this->assertEquals( "Advanced admin", $this->getText( "link=Advanced admin" ) );
$this->click( "css=a[title='Sign Out']" );
$this->click( "id=bot2-Msg1" );
$this->waitForPageToLoad( "30000" );
$this->assertEquals( "Login is vereist", $this->getText( "css=h2" ) );
}
}
解决方法:
将它移动到构造函数(或任何其他函数) – 您似乎没有该类的任何构造函数,但无论如何都将调用__construct:
protected $screenshotPath = '';
public function __construct() {
$this->$screenshotPath = __DIR__ . "/FailedTestsScreenshots";
}
或者进入SetUp():
protected function SetUp() {
$this->$screenshotPath = __DIR__ . "/FailedTestsScreenshots";
$this->setBrowser( "*firefox" );
$this->SetBrowserUrl( $this->path );
}
内容总结
以上是互联网集市为您收集整理的php – 函数外部的变量中不允许表达式全部内容,希望文章能够帮你解决php – 函数外部的变量中不允许表达式所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。