Home >Backend Development >PHP Tutorial >请教大家一个关于php类的问题

请教大家一个关于php类的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:43:57919browse

1.php

<?php class test{    public $a = include('./2.php');	  	function testa()	{	   print_r( $this->a);		}}$test = new test;$test->testa();?>


2.php
<?php  return array('status'=>1);?>


 通过1.php  输出2.php 里的数组 但是总是报错 请教大家应该怎么写


回复讨论(解决方案)

class test{    public $a;    function test() {      $this->a =  = include('./2.php');    }    function testa()    {       print_r( $this->a);         }}

class test{    public $a;     public function __construct() {      $this->a = include('./2.php');    }     function testa()    {       print_r( $this->a);          }}

放在方法里引入

谢谢大家的热心回答

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn