我的应用程序结构:如何扩展多个类
E:\ WAMP \ WWW \手机\模块\ mod_expense.php类名称:mod_expense Descrition:包含INSERT,DELETE,UPATE操作,也该CLAS延伸con_class CLASS
E:\瓦帕\ WWW \移动\控制器\ contr_busniss.php类名:con_class描述:内含选择查询的业务逻辑
E:\瓦帕\ WWW \移动\视图\ expenditure \ expense.php说明:包含expense.html CLASS和contr_busniss.php CLASS目的:使用此文件应用程序运行例如,如果要显示费用ADD FORM,那么我的URL看起来像似乎是http:// localhost/mobile/view/expenditure/?expense.php FP =添加 费用,查看表单,然后我的URL看起来likg http://localhost/mobile/view/expenditure/expense.php?fp=view
E:\ WAMP \ WWW \手机\图\支出\ expense.html.php类名称:expense_html_form描述:包含FORM(添加费用,编辑费用,查看费用)以及此类扩展con_class CLASS
现在我有Database类:CLASS Name是DB_Class ,我想在mod_expense.php & expense.html.php中使用这些类函数,我不太熟悉OOPS,
当前这些文件已经扩展了con_class CLASS,现在我想扩展Database类,如何延长DB类在这里,
我很少在这里摘录:
文件名:expense.php
include("../../include/config.php");
include("../../include/dbclass.php");
include_once("expense.html.php");
include("../../controller/con_error.php");
include_once("mod_expense.php");
$obj_dbclass = new dbClass();
$obj_dbclass->db_connect();
$expense_object = new expense_html_form();
$expense_object->expense_add();
if(isset($_POST['submit'])){
$mod_expense = new mod_expense();
echo $mod_expense->ins_expense();
}
费尔Ë名称:expense.html.php
class expense_html_form{
function expense_add(){
ADD FORM
}
}
文件名:mod_expense.php
class mod_expense extends con_class{
function ins_expense(){
EXPENSE ADD FUNCTIONALITY
}
}
文件名:contr_busniss.php
class con_class{
function check_already_exist($amount){
echo "SELECT expense_amount FROM expense WHERE expense_amount = '$amount'";
$select=mysql_query("SELECT count(expense_amount) FROM expense WHERE expense_amount = '$amount'");
$row=mysql_fetch_array($select);
$op=$row[0];
return $op;
}
}
现在我想延长DBClass函数。建议如何实现。
问题太长了。 –
简单的如何实现当我们想要扩展多个类 – vlk
PHP不支持多继承,如果这是你正在寻找的。看看[这个问题](http://stackoverflow.com/questions/3889080/php-oop-structure-problem-simulate-multiple-inheritance)。 – Jon