-1
我是Php OOP的概念新手..我試圖在一個表(index.php)文件中打印書名,該表中的書詳細信息位於不同的類文件中(FirstExample.php)。我得到了在類解析錯誤file.I檢查我的代碼twice..But我不明白的錯誤,我已經做了..解析錯誤:意外(T_variable)期望函數(T_FUNCTION)
<?php
class FirstExample {
var $book;
var $price;
public function getBookName($bookname){
$this->book = $bookname;
echo "The bookname you Ordered is $book";
}
public function getBookPrice($bookPrice){
$this->price = $bookPrice;
echo "The Book Price is $price";
}
$physics = new FirstExample;
$chemistry = new FirstExample;
$Mathematics = new FirstExample;
$computerProgramming = new FirstExample;
$physics->getBookName("Physics");
$physics->getBookPrice("$150");
$chemistry->getBookName("Chemistry");
$chemistry->getBookPrice("$100");
$Mathematics->getBookName("Mathematics-Differential and Integral Calculas");
$Mathematics->getBookPrice("$200");
$computerProgramming->getBookName("Advanced Computer Programming");
$computerProgramming->getBookPrice("$200");
}
?>
關閉與'類}'getBookPrice後' '定義 –
移動}根據函數getBookPrice(....)...關閉你的類定義 – donald123
謝謝@ donald123和@ Nordenheim – Madhi