当前位置: 首页>>代码示例>>PHP>>正文


PHP String::isEmpty方法代码示例

本文整理汇总了PHP中String::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP String::isEmpty方法的具体用法?PHP String::isEmpty怎么用?PHP String::isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在String的用法示例。


在下文中一共展示了String::isEmpty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isEmpty

 /**
  * Check if resource is empty
  *
  * @param resource $resource The resource
  *
  * @return bool
  */
 public static function isEmpty($resource)
 {
     if (!self::isValid($resource) && null !== $resource) {
         return false;
     }
     return String::isEmpty($resource);
 }
开发者ID:OliverMonneke,项目名称:pennePHP,代码行数:14,代码来源:Resource.php

示例2: parameterValidation

 public static function parameterValidation($file)
 {
     if (!(String::isEmpty($file, $trim = TRUE) === FALSE)) {
         return -1;
     }
     return getimagesize(new File($file)) ? TRUE : -2;
 }
开发者ID:pthreat,项目名称:apf-dev,代码行数:7,代码来源:Image.class.php

示例3: __construct

    /**
     * Initializes a new File Object from parent and child or just parent.
     */
    public function __construct($parent = "", $child = "") {
        $parent = new String($parent);
        $child = new String($child);
        
        if($parent->isEmpty())
            throw new Exception("File path cannot be empty.");
            
        if($parent->isEmpty() && $child->isEmpty())
            throw new Exception("File path cannot be empty.");

        if($parent->substring(-1) == $this::seperatorChar && !$child->isEmpty())
            $this->path = $parent . $child;
        else if(!$child->isEmpty())
            $this->path = $parent . $this::seperatorChar . $child;
        else
            $this->path = $parent;
	}
开发者ID:nijikokun,项目名称:java.php,代码行数:20,代码来源:File.java.php

示例4: parameterValidation

 /**
  * Private method which normalizes email argument validation throughout all of the 
  * contained methods of this class.
  * @param String $email
  * @return Int -1 Given argument is not a string
  * @return Int -2 Given argument is empty
  * @return boolean TRUE argument is a valid email
  * @return boolean FALSE $email argument is an invalid email
  */
 public static function parameterValidation($email)
 {
     if (!String::isString($email)) {
         return -1;
     }
     if (String::isEmpty($email, $useTrim = TRUE)) {
         return -2;
     }
     $addressDomain = substr($email, strpos($email, '@') + 1);
     $mxRecords = array();
     if (!getmxrr($addressDomain, $mxRecords)) {
         return -3;
     }
     return filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE ? -4 : TRUE;
 }
开发者ID:pthreat,项目名称:apf-dev,代码行数:24,代码来源:Email.class.php

示例5: hasMethod

 /**
  *Checks if a class has a method named $method (boolean mode)
  *
  *@param String $name class name
  *@param String $method method to be checked 
  *@param Mixed  $filters, a set of filters to check for class attributes such as public,
  *					private, abstract, final, etc. You can specify a string such as "abstract"
  *					or you can specify a set of filters in an Array like structure
  *					for instance, specifying $filters to  Array('static','public') 
  *					would check for a method named $method that is both static AND public.
  *					Note: This is affected according to the mode you specify, 
  *					which is by default "all", meaning that every filter you specify
  *					must be present in the given method.
  *
  *@param String	$mode mode can be any of "all", "any" or "some". The default mode is "all"
  *
  *					"all" mode: the method must contain ALL and *ONLY* the parameters that you 
  *					specify in the $filters argument. If it contains extra attributes it will be
  *					considered as invalid.
  *
  *					"any" mode: the method must contain at least ONE of the parameters specified
  *					in $filters. Extra attributes don't matter.
  *
  *					"some" mode: the method must contain all of the attributes specified in
  *					$filters, but if it contains any other attribute it's still considered 
  *					valid.
  *					
  *					is necessary to exist in the given method for it to be TRUE.
  *					
  *					
  *@param String $msg Exception message if any
  *@param Int $exCode Exception code
  *
  *@return Int -6 if $filters are not null and an empty string was entered
  *@return Int -7 if $filters are an array but the array elements are not strings or it's empty
  *@return Int -8 ONLY if specified filters are empty
  *@return Int -9 ONLY if an invalid filter was specified
  *@return Int -10 Method doesn't exists
  *@return boolean TRUE if the class has a method named $method
  *@return boolean FALSE if the class doesn't has a method named $method
  *
  *@see self::parameterValidation for other return values
  */
 public static function hasMethod($name, $method, $filters = NULL, $mode = "all")
 {
     $validModes = array('all', 'any', 'some');
     $stdValidation = self::parameterValidation($name, $method);
     //something went wrong
     if (!($stdValidation === TRUE)) {
         return $stdValidation;
     }
     $rc = new \ReflectionClass($name);
     //If no filters where specified, then check if the given class has a given method
     //and thats it! We don't need further checking if the user hasn't specified any filters.
     if (is_null($filters)) {
         return $rc->hasMethod($method);
     }
     //Check if specified $filters are invalid
     if (is_string($filters)) {
         if (String::isEmpty($filters)) {
             return -6;
         }
     }
     //If it's an array but the array is not made of strings
     if (!is_null(Vector::isArray($filters)) && !Vector::isMadeOfStrings($filters)) {
         return -7;
     }
     if (is_string($filters)) {
         $filters = array($filters);
     }
     $mode = strtolower($mode);
     //Specified $mode is invalid (not one of all,any or some)
     if (String::isEmpty($mode) || !in_array($mode, $validModes)) {
         return -7;
     }
     //Check if entered filters are not empty
     if (empty($filters)) {
         return -8;
     }
     //Check if entered filters are valid
     foreach ($filters as $filter) {
         $filter = sprintf('IS_%s', strtoupper($filter));
         //If an invalid filter is detected, then return -9
         if (!self::hasConstant('\\ReflectionMethod', $filter)) {
             return -9;
         }
     }
     //Fetch all class methods
     $methods = $rc->getMethods();
     $found = FALSE;
     foreach ($methods as $m) {
         //If the current method is not equal to the selected one then continue
         //with the next element in the array
         if ($m->name !== $method) {
             continue;
         }
         $found = TRUE;
         break;
     }
     //Method not found
//.........这里部分代码省略.........
开发者ID:pthreat,项目名称:apf-dev,代码行数:101,代码来源:Class_.class.php

示例6: explode

 /**
  * Convert a string to an array
  *
  * @param string $string    The string
  * @param string $delimiter The delimiter
  *
  * @return array
  */
 public static function explode($string, $delimiter)
 {
     if (!String::isValid($string) || String::isEmpty($string)) {
         return false;
     }
     return explode($delimiter, $string);
 }
开发者ID:OliverMonneke,项目名称:pennePHP,代码行数:15,代码来源:Collection.php

示例7: isMadeOfStrings

 /**
  * Validates that an array like structure is made of strings
  * @param Mixed $array
  * @param boolean $nonEmpty whether or not the strings contained inside the array can be empty
  * @return boolean TRUE
  * @return Mixed Index position where the failure condition has been found.
  */
 public static function isMadeOfStrings($array, $nonEmpty = TRUE)
 {
     $stdValidation = self::parameterValidation($array);
     if (!($stdValidation === TRUE)) {
         return $stdValidation;
     }
     foreach ($array as $key => $val) {
         if (is_object($val)) {
             if (!Object::hasMethod($val, "__toString")) {
                 return $key;
             }
             //print the object
             $val = sprintf('%s', $val);
         }
         if ($nonEmpty && String::isEmpty($val)) {
             return $key;
         }
     }
     return TRUE;
 }
开发者ID:pthreat,项目名称:apf-dev,代码行数:27,代码来源:Vector.class.php

示例8: random

 /**
  * Generate random number
  *
  * @param int $min Minimum value
  * @param int $max Maximum value
  *
  * @return int
  */
 public static function random($min, $max = null)
 {
     if (String::isEmpty($max) || $max > getrandmax()) {
         $max = getrandmax();
     }
     return rand($min, $max);
 }
开发者ID:OliverMonneke,项目名称:pennePHP,代码行数:15,代码来源:Number.php

示例9: setVersion

 /**
  * Sets the requested Exchange server version
  * @param string $version
  * @return null
  * @throws zibo\ZiboException when the provided version is empty
  */
 protected function setVersion($version)
 {
     if ($version === null) {
         $version = self::DEFAULT_VERSION;
     } elseif (String::isEmpty($version)) {
         throw new ZiboException('Provided version is empty');
     }
     $this->version = $version;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:15,代码来源:Client.php

示例10: testIsEmpty

 public function testIsEmpty()
 {
     $o = new String(self::MULTI_LINE);
     $this->assertFalse($o->isEmpty());
     $o = new String('');
     $this->assertTrue($o->isEmpty());
 }
开发者ID:netconstructor,项目名称:LampCMS,代码行数:7,代码来源:StringTest.php

示例11: Database

$database = new Database();
// initialize class
$database->connect();
// connect to db
LookbookDatabase::$database = $database;
// pass database accessor
//email-redirect.php?email=mrjesuserwinsuarez@gmail.com&action=private-beta&redirect=TRUE
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=signup&redirect=TRUE
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=remove&redirect=TRUE
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=open&redirect
//email-redirect.php?&email=mrjesuserwinsuarez@gmail.com&action=Recieved Invitation&redirect
// $action      = 'signup';
// $id          = 1;
// $email       = 'mrjesuserwinsuarez@gmail.com';
//other initialized
$defaultLink = 'http://fashionsponge.com/';
$action = String::isEmpty($_GET['action'], '');
$email = String::isEmpty($_GET['email'], '');
$redirect = String::isEmpty($_GET['redirect'], FALSE);
$qid = !empty($_GET['qid']) ? $_GET['qid'] : 0;
$fname = LookbookDatabase::getFullNameByEmail($email);
//notification send to admin when email clicked action
$to = Program::$adminEmail;
//'mrjesuserwinsuarez@gmail.com,pecotrain1@gmail.com';
$subject = 'invited person clicked the email content ' . $action;
$body = 'Email: ' . $email . "\n" . 'First Name: ' . $fname . "\n" . ' Action: ' . $action;
$from = $email;
$title = 'FS ' . $action;
echo "<div style='display:none' >";
Program::emailInvitationClickedSaveActivityAndRedirectLocation($defaultLink, $action, $redirect, $to, $subject, $body, $from, $title, $qid, $email);
echo "</div>";
开发者ID:jesus143,项目名称:fs-dev,代码行数:31,代码来源:email-redirect.php

示例12: scanTemporaryUploadPath

 private function scanTemporaryUploadPath(Io_Path $path_, $subPath_ = '')
 {
     if (false === String::isEmpty($subPath_) && false === String::endsWith($subPath_, '/')) {
         $subPath_ .= '/';
     }
     foreach ($path_ as $entry) {
         if ($entry->isDot()) {
             continue;
         }
         if ($entry->isFile()) {
             $this->stashFile($entry->asFile(), $subPath_);
         } else {
             if ($entry->isDirectory()) {
                 $this->scanTemporaryUploadPath($entry, $subPath_ . $entry->getName());
             }
         }
     }
     $path_->delete(true);
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.ui,代码行数:19,代码来源:file.php

示例13: testIsEmpty

 public function testIsEmpty()
 {
     $string = new String();
     $this->assertTrue($string->isEmpty());
 }
开发者ID:reoring,项目名称:sabel,代码行数:5,代码来源:String.php


注:本文中的String::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。