當前位置: 首頁>>代碼示例>>PHP>>正文


PHP System::__get方法代碼示例

本文整理匯總了PHP中Contao\System::__get方法的典型用法代碼示例。如果您正苦於以下問題:PHP System::__get方法的具體用法?PHP System::__get怎麽用?PHP System::__get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Contao\System的用法示例。


在下文中一共展示了System::__get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __get

 /**
  * Return an object property
  *
  * @param string $strKey The property name
  *
  * @return mixed The property value
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'size':
         case 'filesize':
             return filesize(TL_ROOT . '/' . $this->strFile);
             break;
         case 'name':
         case 'basename':
             if (!isset($this->arrPathinfo[$strKey])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return $this->arrPathinfo['basename'];
             break;
         case 'dirname':
         case 'filename':
             if (!isset($this->arrPathinfo[$strKey])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return $this->arrPathinfo[$strKey];
         case 'extension':
             if (!isset($this->arrPathinfo['extension'])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return strtolower($this->arrPathinfo['extension']);
             break;
         case 'origext':
             if (!isset($this->arrPathinfo['extension'])) {
                 $this->arrPathinfo = $this->getPathinfo();
             }
             return $this->arrPathinfo['extension'];
             break;
         case 'tmpname':
             return basename($this->strTmp);
             break;
         case 'path':
         case 'value':
             return $this->strFile;
             break;
         case 'mime':
             return $this->getMimeType();
             break;
         case 'hash':
             return $this->getHash();
             break;
         case 'ctime':
             return filectime(TL_ROOT . '/' . $this->strFile);
             break;
         case 'mtime':
             return filemtime(TL_ROOT . '/' . $this->strFile);
             break;
         case 'atime':
             return fileatime(TL_ROOT . '/' . $this->strFile);
             break;
         case 'icon':
             return $this->getIcon();
             break;
         case 'dataUri':
             return 'data:' . $this->mime . ';base64,' . base64_encode($this->getContent());
             break;
         case 'imageSize':
             if (empty($this->arrImageSize)) {
                 if ($this->isGdImage) {
                     $this->arrImageSize = @getimagesize(TL_ROOT . '/' . $this->strFile);
                 } elseif ($this->isSvgImage) {
                     $doc = new \DOMDocument();
                     if ($this->extension == 'svgz') {
                         $doc->loadXML(gzdecode($this->getContent()));
                     } else {
                         $doc->loadXML($this->getContent());
                     }
                     $svgElement = $doc->documentElement;
                     if ($svgElement->getAttribute('width') && $svgElement->getAttribute('height') && substr(rtrim($svgElement->getAttribute('width')), -1) != '%' && substr(rtrim($svgElement->getAttribute('height')), -1) != '%') {
                         $this->arrImageSize = array(\Image::getPixelValue($svgElement->getAttribute('width')), \Image::getPixelValue($svgElement->getAttribute('height')));
                     }
                     if ($this->arrImageSize && $this->arrImageSize[0] && $this->arrImageSize[1]) {
                         $this->arrImageSize[2] = 0;
                         // replace this with IMAGETYPE_SVG when it becomes available
                         $this->arrImageSize[3] = 'width="' . $this->arrImageSize[0] . '" height="' . $this->arrImageSize[1] . '"';
                         $this->arrImageSize['bits'] = 8;
                         $this->arrImageSize['channels'] = 3;
                         $this->arrImageSize['mime'] = $this->getMimeType();
                     } else {
                         $this->arrImageSize = false;
                     }
                 }
             }
             return $this->arrImageSize;
             break;
         case 'width':
             return $this->imageSize[0];
             break;
         case 'height':
//.........這裏部分代碼省略.........
開發者ID:bytehead,項目名稱:core-bundle,代碼行數:101,代碼來源:File.php

示例2: __get

 /**
  * Return an object property
  *
  * @param string $strKey The property name
  *
  * @return mixed The property value
  */
 public function __get($strKey)
 {
     if (isset($this->arrData[$strKey])) {
         return $this->arrData[$strKey];
     }
     return parent::__get($strKey);
 }
開發者ID:qzminski,項目名稱:contao-core-bundle,代碼行數:14,代碼來源:User.php


注:本文中的Contao\System::__get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。