2 回答
TA贡献1884条经验 获得超4个赞
ObjectModel.php 文件
<?php
class ObjectModel{
//For example I created non-static function in ObjectModel class
public function getStockAvailableIdByProductId($id){
return "test";
}
//For example I created static function in ObjectModel class
public static function getStockAvailableIdByProductIdStatic($id){
return "teststatic";
}
}
?>
StockAvailable.php 文件。
<?php
//Extends used to inherit the parent class property
class StockAvailableCore extends ObjectModel
{
public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
{
}
}
?>
运行.php文件
<?php
require_once('ObjectModel.php');
require_once('StockAvailable.php');
$MyClass = new StockAvailableCore();
// Access the ObjectModel function
//to access the Non-static method need to create the object.
echo $MyClass->getStockAvailableIdByProductId($id);
//Static method access by class reference (::)
echo StockAvailableCore::getStockAvailableIdByProductIdStatic($id);
?>
- 2 回答
- 0 关注
- 137 浏览
添加回答
举报