设为首页 加入收藏

TOP

PHP7.27: object(一)
2019-09-03 02:41:31 】 浏览:77
Tags:PHP7.27: object

 http://www.devshed.com/c/a/PHP/PHP-Services-Layers-Data-Mappers/

https://stackoverflow.com/questions/1980015/model-mapper-relationship

http://assets.en.oreilly.com/1/event/36/PHP%20Object-Relational%20Mapping%20Libraries%20In%20Action%20Presentation.pdf

https://github.com/marcelgsantos/learning-oop-in-php

https://github.com/domnikl/DesignPatternsPHP/tree/master/Structural/DataMapper

https://www.sitepoint.com/handling-collections-of-aggregate-roots/

https://www.sitepoint.com/integrating-the-data-mappers/

https://github.com/TwisterMW/php-dal-model

http://www.phpdao.com/

 

 

<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">		
<meta charset="utf-8">
<title>object 对象</title>
<meta name="keywords" content="geovindu">
<meta name="description" content="涂聚文">		
</head>

<body>
	
<?php

// object
class User
{
	public $username,$password;
	
	function getName()
	{
		return $this->username;
	}
	
	function getPassword()
	{
		return $this->password;
		
	}
	

	
	function Save()
	{
		echo("保存成功!");
	}
	
}
// UserDesc 继承 User类
class UserDesc extends User
{
	public $realname,$email,$birthday;
	
	function getRealname()
	{
		return $this->realname;
		
	}
	
	function getEmail()
	{
		return $this->email;
	}
	
	function getBirthday()
	{
		return $this->birthday;	
	}
	
}

function getMillisecond()
{ 
	list($s1,$s2) = explode(' ', microtime());
	return (float)sprintf('%.0f', (floatval($s1)+floatval($s2)) * 1000); 
}
	
$object=new User;
print_r($object);echo("<br/>");

$object->username="geovindu"; //
$object->password="888888";// 赋值
print_r($object);echo("<br/>");
$object->Save()	;//显示文字
echo("姓名:".$object->getName());	//显示对象的name值
echo("密码:".$object->getPassword());
$object2=new UserDesc;
$object2->birthday=date('Y-m-d H:i:s');
$object2->email='geovindu@163.com';
$object2->realname='涂聚文';
$object2->username='geovindu';
$object2->password='8888';

print_r($object2);echo("<br/>");

//
class Collection implements ArrayAccess,IteratorAggregate
{
    public $objectArray = Array();
    //**these are the required iterator functions    
    function offsetExists($offset)
    {          
        if(isset($this->objectArray[$offset]))  return TRUE;
        else return FALSE;          
    }    
    
    function & offsetGet($offset)
    {   
        if ($this->offsetExists($offset))  return $this->objectArray[$offset];
        else return (false);
    }
    
    function offsetSet($offset, $value)
    {          
        if ($offset)  $this->objectArray[$offset] = $value;
        else  $this->objectArray[] = $value;
    }
    
    function offsetUnset($offset)
    {
        unset ($this->objectArray[$offset]);
    }
    
    function & getIterator()
    {
        return new ArrayIterator($this->objectArray);
    }
    //**end required iterator functions

    public function do
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇php intval 下一篇PHP高级面试题

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目