PHP构造函数引用变量以使其他变量不起作用

PHP构造函数引用变量以使其他变量不起作用,php,constructor,Php,Constructor,我有一个构造函数。除了最后一部分,一切都正常 class Article { public $category; public $title; public $text; public $intro; public function __construct($category, $title, $text) { $this->category = $category; $this->title = $title; $

我有一个构造函数。除了最后一部分,一切都正常

class Article {
  public $category;
  public $title;
  public $text;
  public $intro;


  public function __construct($category, $title, $text) {
      $this->category = $category;
      $this->title = $title;    
      $this->text = $text;
      $this->intro = substr($this->text, 0, 40);
  }
}

没有创建简介。

它工作正常:

<?php

class Article {
  public $category;
  public $title;
  public $text;
  public $intro;


  public function __construct($category, $title, $text) {
      $this->category = $category;
      $this->title = $title;    
      $this->text = $text;
      $this->intro = substr($this->text, 0, 40);
  }
}

$test=new Article('a','b','A question is a linguistic expression used to make a request for information, or the request made using such an expression. The information requested may be provided in the form of an answer.');

echo $test->intro; //A question is a linguistic expression us

哪一个是“最后一部分”以及它是如何不起作用的?请不要让免费帮助猜测Intro没有被创建。你能用不起作用的代码编辑吗?