تقصد كدة؟
كود PHP:
<?php
class helal2{
public function echo_name($name){
echo $name;
}
}
class helal{
function get_helal2_object(){
return new helal2();
}
}
$helal = new helal();
$r = $helal->get_helal2_object();
$r->echo_name('Mohamed');
?>
جزاك الله خيرا اخي الكريم
ممكن تجرب الكلاس ده وتقلي
كود PHP:
<?php
###################################
/**
* @author mohamedhelal
* mohamed_helal123456@hotmail.com
* برمجة محمدهلال
* جميع حقوق هذا السكربت لمحمدهلال
* سكربت helalEGYPT
* سكربت El_Masry
* mohamedhelal
* @copyright 2009
*/
####################################
class DB_CLass
{
protected $HOST="localhost";
protected $DB_USERNAME="";
protected $DB_PASSWORD="";
protected $DB_NAME="";
protected $DB_CONTENT;
protected $SERV_CONTENT;
protected $SQL_RESULT;
########################################################
########################################################
function _construct($host,$user,$pass,$db)
{
$this->HOST=$host;
$this->DB_USERNAME=$user;
$this->DB_PASSWORD=$pass;
$this->DB_NAME=$db;
$this->__CONTENT();
$this->__DESCONTENT();
}
protected function __CONTENT()
{
$this->SERV_CONTENT=@mysql_connect($this->HOST,$this->DB_USERNAME,$this->DB_PASSWORD);
$this->DB_CONTENT=@mysql_select_db($this->DB_NAME,$this->SERV_CONTENT);
return $this->DB_CONTENT;
}
protected function __DESCONTENT()
{
if(!$this->SERV_CONTENT)
{
die("<h1 align='center'>خطاء في الاتصال بسيرفر قاعدة البيانات</h1>");
}
elseif(!$this->DB_CONTENT)
{
die("<h1 align='center'>خطاء في الاتصال بقاعدة البيانات</h1>");
}
}
function SQL($sql)
{
return @mysql_query($sql) ;
}
function QUER($SQL)
{
$SQL=$this->SQL($SQL);
$FETCH=$this->FETCH($SQL);
$num=$this->row($SQL);
$arr=(object)array("FETCH"=>$FETCH,"num"=>$num);
return $arr;
}
function FETCH($SQL)
{
$row=@mysql_fetch_array($SQL);
return $row;
}
function row($SQL)
{
$num=@mysql_num_rows($SQL);
return $num;
}
}
$helal=new DB_CLass();
$DB['HOST']="localhost";
$DB['USERNAME']="root";
$DB['PASSWORD']="123456";
$DB['DB_NAME']="test2";
$helal->_construct($DB['HOST'],$DB['USERNAME'],$DB['PASSWORD'],$DB['DB_NAME']);
$r=$helal->QUER("select*from names");
echo $r->num."<br>";
foreach($r->FETCH as $row)
{
print_r($row."<br>");
}
?>
جربة وقلي