我正在使用 php7 的类型提示。所以我有以下代码
class Uni
{
/**
* @var Student
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Student")
* @ORM\JoinColumn(nullable=false)
*/
private $student;
function _construct(){
$this->student= new Student();
}
/**
* Set student
*
* @param \AppBundle\Entity\Student $student
*
* @return Uni
*/
public function setStudent (Student $student): Uni
{
$this->student= $student;
return $this;
}
/**
* Get student
*
* @return \AppBundle\Entity\Student
*/
public function getStudent(): Student
{
return $this->student;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试为 Uni 加载新表单时,出现此错误
Type error: Return value of AppBundle\Entity\Uni::getStudent() must be an …Run Code Online (Sandbox Code Playgroud) 构造函数功能在 PHP 7.0.x 中已弃用,那么我如何以其他方式使用或访问此变量?任何人都可以有想法吗?请帮助我找到正确的解决方案...
例如:
public function __construct() {
$this->user = new User();;
}
Run Code Online (Sandbox Code Playgroud)
我们如何定义这个?
a) 每次处理代码时 __destruct 都会单独运行吗
b) 或者,不,您需要使用 unset($objectName) 才能运行(另一个选项是 register_shutdown_function() )。
c) 还有其他方面与此相关吗?就像它在这个或那个时自行工作一样,你也可以使用这个或那个来让它运行,任何东西......
我有一个问题,在我使用Laravel的14个月中从未遇到过。
我有一个用户注册系统。任何应用程序权利的基本要求。我有通常的凭据名称,用户名,电子邮件,密码和电话号码。
如果我以以下格式提交号码086123456。则从数据库中保存的内容中删除了前导0。phone_number字段是整数。
不知道这是怎么回事。
用户模型
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Property;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
protected $fillable = [
'first_name', 'last_name', 'username', 'email', 'phone_number', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
public function properties()
{
return $this->hasMany(Property::class);
}
public function getJWTIdentifier()
{
return $this->getKey();
}
public function getJWTCustomClaims()
{
return [];
}
}
Run Code Online (Sandbox Code Playgroud)
注册功能
public function …Run Code Online (Sandbox Code Playgroud) 我想知道为什么php函数list()在Max OSx上不起作用,但在Windows上却起作用.
list($songAuthor, $songName, $songDate, $songSummary, $songPic, $songLyrics) = split(";", $data, 6);
Run Code Online (Sandbox Code Playgroud)
我正在尝试将字符串解析$data为六个不同的变量.
我的PHP版本是7.0.8.
如何在Mac OSx中运行代码?
我有这样的感觉:
public function isSuperAdmin() {
if($this->role->id == '1') {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
它如何最大化简化?