2011-12-07 5 views
0

나는 우분투 11.10에 있습니다. echo phpinfo();과 같은 간단한 스크립트를 작성하면 오류가 표시됩니다. 하지만 일부 추가 PHP 코드를 작성하려고하면 브라우저 서버 오류 페이지가 표시됩니다. 내가 이해하지 못하는 문제는 무엇인가? ??우분투에서 PHP 서버 오류 11.10

코드를 다음과 같이 변경하면 서버 오류가 발생합니다.

<?php 
class MyClass{ 
    private $prop; 
    public function __construct(){ 
     echo "The class \"".__CLASS__."\"was created"; 
    } 
    public function __destruct(){ 
     echo "The class \"".__CLASS__."\" was destroyed"; 
    } 
    protected function getProperty(){ 
     return $prop; 
    } 
    public function __toString(){ 
     echo "__toString() method called.<br />"; 
     return $this->getProperty().'<br />'; 
    } 
    public function setProperty($prop){ 
     $this->prop = $prop; 
    } 
} 
class MyOtherClass extends MyClass{ 
    public function __construct(){ 
     parent::__contruct(); 
     echo "A new constructor in class \"".__CLASS__"\""; 
    } 
    public function newMethod(){ 
     echo 'From a new method in class '.__CLASS__.'<br />'; 
    } 
} 
$newClass = new MyOtherClass(); 
echo $newClass->getProperty(); 
?> 
+0

코드 샘플을 제공해 주시겠습니까? – Mike

+0

질문을 수정했습니다 ... – Sandeep

+0

Sever Error 란 무엇입니까? – Shad

답변

3
class MyClass{ 
    protected getProperty(){ 
    //... 

    public __toString(){ 
    //... 

    public setProperty($prop){ 
    //... 

class MyOtherClass extends MyClass{ 
    public __construct(){ 
    // ... 

당신은 여러 가지 방법으로 public/protectedfunction을 놓치고있어.


커플 이상의 오류가 :

class MyOtherClass extends MyClass{ 
    public function __construct(){ 
     parent::__contruct(); 
     echo "A new constructor in class \"".__CLASS__"\""; 
    } 
    //... 
  • 당신은 s없이 parent::_construct() 철자.
  • echo 줄에 __CLASS__ 뒤에 연결 연산자가 누락되었습니다 (.). 당신이 밖으로 여기에서 호출 할 수 있도록

  • MyClass::getProperty()

    echo $newClass->getProperty();protected입니다.

+0

코드에 실수가 있어도 PHP 인터프리터가 오류로 응답해야합니다. 어쨌든, 위의 코드를 편집하고 동일한 오류가 계속 발생합니다. – Sandeep

+0

때때로 PHP 오류는 서버 설정에 따라 실제로 500 개의 서버 오류를 발생시킵니다. 오류 로그에 무엇이 있습니까? – Wiseguy

+0

HTTP 오류 500 (내부 서버 오류) : 서버가 요청을 수행하는 동안 예기치 않은 상황이 발생했습니다. – Sandeep

관련 문제