Home > Download >  Library download

  • <?php interface IHuman {   function GetName(); } class ManClass implements IHuman {   public function GetName()   {     return "I'm man."."<br>";   } } class WomanClass implements IHuman {   public function GetName()   {     return "I'm Woman."."<br>";   } }In object-oriented programming, the most common method is a new operator to generate an object instance, and the new operator is used to construct an object instance. But in some cases, the new operator directly generating objects will cause some problems. For example, the creation of many types of objects requires a series of steps: you may need to calculate or obtain the object's initial settings; choose which sub-object instance to generate; or you must generate some helper objects before generating the object you need. In these cases, the creation of a new object is a "process", not just an operation, like a gear transmission in a larger machine.

    Other libraries22902018-01-08
  • <?php   public function setEncode($incode,$outcode){     $this->inEncode=$incode;     $this->outEncode=$outcode;   }   public function setTitle($titlearr){     $title="";     foreach($titlearr as $v){       if($this->inEncode!=$this->outEncode){         $title.=iconv($this->inEncode,$this->outEncode,$v)."\t";       }       else{         $title.=$v."\t";       }     }     $title.="\n";     return $title;   }Usage method$excel=new Excel();Set encoding:$excel->setEncode("utf-8" ,"gb2312"); //If you don't want to transcode, just write the same parameters, for example $excel->setEncode("utf-8","utf-8");settings Title bar$titlearr=array("a","b","c","d");Set content bar$contentarr=array(1=>array("ab","ac","ad","ae"),2=>array( "abc","acc","adc","aec"),3=>array("abd","acd","add","aed"),4=>array("abe","ace","ade","aee"), ); $excel->getExcel($titlearr,$ contentarr,"abc");

    Other libraries29032018-01-08
  • <?php class Foo {   const BAR = 'bar';   public static function getConstantValue()   {     return self::BAR;   }   public function getConstant()   {     return self::BAR;   } } $foo = 'Foo'; echo $foo::BAR, '<br />'; echo Foo::BAR, '<br />'; $obj = new Foo(); echo $obj->getConstant(), '<br />'; echo $obj->getConstantValue(), '<br />'; echo Foo::getConstantValue(); class Bar extends Foo {   const BAR = 'foo';    public static function getMyConstant()   {     return self::BAR;   }   public static function getParentConstant()   {     return parent::BAR;   } } echo Bar::getMyConstant(); // foo echo Bar::getParentConstant(); // barClass constants belong to the class itself, not to object instances, and cannot be accessed through object instancesCannot be modified with public, protected, private, staticSubclasses can override parent classes The constants in the parent class can be called through (parent::) Since PHP5.3.0, a variable can be used to dynamically call the class. But the value of this variable cannot be the keyword

    Other libraries22382018-01-08
  • <?php class time{   private $year;//年   private $month;//月   private $day;//天   private $hour;//小时   private $minute;//分钟   private $second;//秒   private $weekday;//星期   private $longDate;//完整的时间格式   private $diffTime;//两个时间的差值   //返回年份 time:时间格式为时间戳  2016-8-27   function getyear($time="",$type=""){     if($time==""){       $time=time();     }     if($type==1){       return $this->year=date("y",$time); //返回两位的年份 16     }else{       return $this->year=date("Y",$time); //返回四位的年份 2016     }   }   //返回当前时间的月份 time:时间格式为时间戳 2016-8-27   function getmonth($time="",$type=""){     if($time==""){       $time=time();     } A complete example of PHP time class, involving PHP's various operating techniques for obtaining and comparing dates, times, days, etc. It is very simple and practical. Friends who need it can refer to it to facilitate everyone to learn and experience PHP code.

    Other libraries32352018-01-06
  • <?php header("Content-Type: text/html; charset=UTF-8"); require("phpQuery.php"); $hj = QueryList::Query('http://mobile.csdn.net/',array("title"=>array('.unit h1','text'))); //dump($hj->data); $data = QueryList::Query('http://cms.querylist.cc/bizhi/453.html',array(     'image' => array('img','src')     ))->data; // $data = QueryList::Query('http://cms.querylist.cc/google/list_1.html',array(     'link' => array('a','href')     ))->data; $page = 'http://cms.querylist.cc/news/566.html'; $reg = array(     'title' => array('h1','text'),     'date' => array('.pt_info','text','-span -a',function($content){         $arr = explode(' ',$content);         return $arr[0];     }),     'content' => array('.post_content','html','a -.content_copyright -script',function($content){                   $doc = phpQuery::newDocumentHTML($content);             $imgs = pq($doc)->find('img');             foreach ($imgs as $img) {                 $src = 'http://cms.querylist.cc'.pq($img)->attr('src');                 $localSrc = 'w/'.md5($src).'.jpg';                 $stream = file_get_contents($src);                 file_put_contents($localSrc,$stream);                 pq($img)->attr('src',$localSrc);             }             return $doc->htmlOuter();     })     ); $rang = '.content'; $ql = QueryList::Query($page,$reg,$rang); $data = $ql->getData(); dump($data); supports crawling websites and crawling. It is very powerful. It is a server-side open source project based on PHP. It allows PHP developers to easily process DOM document content, such as obtaining the headline information of a news website. What's more interesting is that it uses the idea of ​​​​jQuery. You can process the page content just like using jQuery to get the page information you want.

    Other libraries38772018-01-06
  • <?php header("Content-Type:text/html; charset=utf-8"); define('APP_ROOT', str_replace('\', '/', dirname(__FILE__))); function get_tags_arr($title)     { require(APP_ROOT.'/pscws4.class.php');         $pscws = new PSCWS4(); $pscws->set_dict(APP_ROOT.'/scws/dict.utf8.xdb'); $pscws->set_rule(APP_ROOT.'/scws/rules.utf8.ini'); $pscws->set_ignore(true); $pscws->send_text($title); $words = $pscws->get_tops(5); $tags = array(); foreach ($words as $val) {    $tags[] = $val['word']; } $pscws->close(); return $tags; } print_r(get_tags_arr($con)); function get_keywords_str($content){ require(APP_ROOT.'/phpanalysis.class.php'); PhpAnalysis::$loadInit = false; $pa = new PhpAnalysis('utf-8', 'utf-8', false); $pa->LoadDict(); $pa->SetSource($content); $pa->StartAnalysis( false ); $tags = $pa->GetFinallyResult(); return $tags; } print(get_keywords_str($con));No need to install extensions, it comes with a dictionary and is easy to useUses scws, which many people are familiar with, and the other is phpanalysis made by IT PlatoPlease refer to the index.php file example for usage

    Other libraries26492018-01-06
  • <?php class Cart {   //物品id及名称规则,调试信息控制   private $product_id_rule = '\.a-z0-9-_'; //小写字母 | 数字 | ._-   private $product_name_rule = '\.\:a-z0-9-_';//小写字母 | 数字 | ._-:   private $debug = TRUE;   private $_cart_contents = array();   public function __construct() {     //是否第一次使用?     if(isset($_SESSION['cart_contents'])) {       $this->_cart_contents = $_SESSION['cart_contents'];     } else {       $this->_cart_contents['cart_total'] = 0;       $this->_cart_contents['total_items'] = 0;     }     if($this->debug === TRUE) {       //$this->_log("cart_create_success");     }   }PHP's shopping cart class library mainly introduces the shopping cart class implemented by PHP, which can realize basic adding, deleting, statistics and other related functions of the shopping cart. The basic functions of the shopping cart are as follows: 1) Add items Shopping cart 2) Delete items from the shopping cart 3) Update shopping cart item information [1/-1] 4) Statistics of shopping cart items 1. Total items 2. Total quantity 3. Total amount 5) Statistics of single shopping items Statistics of quantity and amount 6) Clear shopping

    Other libraries23992018-01-06
  • <?php class ftp {   public $off;             // 返回操作状态(成功/失败)   public $conn_id;           // FTP连接   function __construct($FTP_HOST,$FTP_PORT,$FTP_USER,$FTP_PASS)   {     $this->conn_id = @ftp_connect($FTP_HOST,$FTP_PORT) or die("FTP服务器连接失败");     @ftp_login($this->conn_id,$FTP_USER,$FTP_PASS) or die("FTP服务器登陆失败");     @ftp_pasv($this->conn_id,1); // 打开被动模拟   }   function up_file($path,$newpath,$type=true)   {     if($type) $this->dir_mkdirs($newpath);     $this->off = @ftp_put($this->conn_id,$newpath,$path,FTP_BINARY);     if(!$this->off) echo "文件上传失败,请检查权限及路径是否正确!";   }Method: FTP connection@FTP_HOST -- FTP host@FTP_PORT --Port@FTP_USER --Username@ FTP_PASS -- Password

    Other libraries21772018-01-06
  • <?php namespace Moontoast\Math; class BigNumberTest extends \PHPUnit_Framework_TestCase {     protected function setUp()     {         ini_set('bcmath.scale', 0);     }     /**      * @covers Moontoast\Math\BigNumber::__construct      * @covers Moontoast\Math\BigNumber::getValue      * @covers Moontoast\Math\BigNumber::getScale      * @covers Moontoast\Math\BigNumber::setValue      * @covers Moontoast\Math\BigNumber::filterNumber      * @covers Moontoast\Math\BigNumber::setDefaultScale      */     public function testConstruct()     {         $bn1 = new BigNumber('9,223,372,036,854,775,808');         $this->assertSame('9223372036854775808', $bn1->getValue());         $this->assertEquals(0, $bn1->getScale());         $bn2 = new BigNumber(2147483647);         $this->assertSame('2147483647', $bn2->getValue());         $this->assertEquals(0, $bn2->getScale());This is a PHP library for processing extremely large numbers. Friends who need it can download it and use it.

    Other libraries25842018-01-05
  • <?php require_once __DIR__.'/../vendor/autoload.php'; use HeyUpdate\Emoji\UnicodeUtil; $configFile = __DIR__.'/../config/index.json'; $template = <<<'TEMPLATE namespace HeyUpdate\Emoji\Index; class CompiledIndex extends BaseIndex {     protected $emojis = {{emojis}};     protected $emojiUnicodes = {{emojiUnicodes}};     /**      * @var array      */     protected $emojiNames = {{emojiNames}};     /**      * @var string      */     protected $emojiUnicodeRegex = {{emojiUnicodeRegex}};     /**      * @var string      */     protected $emojiNameRegex = {{emojiNameRegex}}; }This is a PHP class library for processing emoji. Friends who need it can download it and use it.

    Other libraries21682018-01-05
  • <?php namespace SensioLabs\AnsiConverter\Tests; use SensioLabs\AnsiConverter\AnsiToHtmlConverter; class AnsiToHtmlConverterTest extends \PHPUnit_Framework_TestCase {     public function testConvert($expected, $input)     {         $converter = new AnsiToHtmlConverter();         $this->assertEquals($expected, $converter->convert($input));     }     public function getConvertData()     {         return array(             // text is escaped             array('<span style="background-color: black; color: white">foo <br /></span>', 'foo <br />'),             // newlines are preserved             array("<span style=\"background-color: black; color: white\">foo\nbar</span>", "foo\nbar"),             // backspaces             array('<span style="background-color: black; color: white">foo   </span>', "foobar\x08\x08\x08   "),This is a php class library that converts ANSI to HTML5. Friends who need it can download it and use it.

    Other libraries21172018-01-05
  • <?php header('Content-type: text/plain; charset=UTF-8'); $in = file_get_contents('emoji-data/emoji.json'); $catalog = json_decode($in, true); echo file_get_contents('inc.css'); $max = 0; foreach ($catalog as $item){ $max = max($item['sheet_x'], $max); $max = max($item['sheet_y'], $max); } $fact = 100 / $max; $sheet_size = $max + 1; echo "span.emoji-inner { background-size: {$sheet_size}00%; }\n"; foreach ($catalog as $item){ $unilow = unicode_hex_chars($item['unified']); $pos_x = $item['sheet_x'] * $fact; $pos_y = $item['sheet_y'] * $fact; echo ".emoji$unilow { background-position: {$pos_x}% {$pos_y}% !important; }\n"; } function unicode_hex_chars($str){ $out = ''; $cps = explode('-', $str); foreach ($cps as $cp){This is an emoji expression conversion PHP class library. Friends who need it can download and use it

    Other libraries23342018-01-05