本文整理汇总了PHP中is_null函数的典型用法代码示例。如果您正苦于以下问题:PHP is_null函数的具体用法?PHP is_null怎么用?PHP is_null使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_null函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_fields
public function get_fields()
{
if (is_null($this->fields)) {
$this->fields = $this->build_fields();
}
return $this->fields;
}
示例2: __construct
public function __construct(\SimpleXMLElement $xml = null)
{
parent::__construct($xml);
if (is_null($xml)) {
return;
}
}
示例3: format_time
public function format_time($timestamp, $date_only = false, $date_format = null, $time_format = null, $time_only = false, $no_text = false)
{
global $forum_date_formats, $forum_time_formats;
if ($timestamp == '') {
return __('Never');
}
$diff = ($this->feather->user->timezone + $this->feather->user->dst) * 3600;
$timestamp += $diff;
$now = time();
if (is_null($date_format)) {
$date_format = $forum_date_formats[$this->feather->user->date_format];
}
if (is_null($time_format)) {
$time_format = $forum_time_formats[$this->feather->user->time_format];
}
$date = gmdate($date_format, $timestamp);
$today = gmdate($date_format, $now + $diff);
$yesterday = gmdate($date_format, $now + $diff - 86400);
if (!$no_text) {
if ($date == $today) {
$date = __('Today');
} elseif ($date == $yesterday) {
$date = __('Yesterday');
}
}
if ($date_only) {
return $date;
} elseif ($time_only) {
return gmdate($time_format, $timestamp);
} else {
return $date . ' ' . gmdate($time_format, $timestamp);
}
}
示例4: getRouteParameters
/**
* @return array $routeParameters
*/
protected function getRouteParameters() : array
{
if (is_null(self::$routeParameters)) {
self::$routeParameters = $this->getController()->getRouteParameters();
}
return self::$routeParameters;
}
示例5: string
/**
* Format the string response, default is to just return the string.
*
* @param $value
* @param $format
*
* @return formatted string
*/
public static function string($value, $format = null)
{
if (is_null($format)) {
$format = '%s';
}
return sprintf($format, $value);
}
示例6: get_instance
/**
* Main WP_Currencies instance.
*
* Ensures only one instance of WP_Currencies is loaded.
*
* @since 1.4.0
*
* @return WP_Currencies
*/
public static function get_instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
示例7: errorMessage
/**
* Return a textual error message for a Doctrine error code
*
* @param int|array integer error code,
* null to get the current error code-message map,
* or an array with a new error code-message map
*
* @return string error message
*/
public function errorMessage($value = null)
{
if (is_null($value)) {
return self::$_errorMessages;
}
return isset(self::$_errorMessages[$value]) ? self::$_errorMessages[$value] : self::$_errorMessages[Doctrine_Core::ERR];
}
示例8: getPath
public function getPath($categoryId, $accountId, $delimiter = ' > ')
{
$account = Mage::helper('M2ePro/Component_Ebay')->getCachedObject('Account', $accountId);
$categories = $account->getChildObject()->getEbayStoreCategories();
$pathData = array();
while (true) {
$currentCategory = NULL;
foreach ($categories as $category) {
if ($category['category_id'] == $categoryId) {
$currentCategory = $category;
break;
}
}
if (is_null($currentCategory)) {
break;
}
$pathData[] = $currentCategory['title'];
if ($currentCategory['parent_id'] == 0) {
break;
}
$categoryId = $currentCategory['parent_id'];
}
array_reverse($pathData);
return implode($delimiter, $pathData);
}
示例9: getMage2StoreId
public static function getMage2StoreId($mage1StoreId)
{
$id = NULL;
if (isset($mage1StoreId)) {
if (is_null($mage1StoreId)) {
$id = 'NULL';
} else {
$cacheId = "store_id2_{$mage1StoreId}";
$val = Yii::app()->cache->get($cacheId);
if (!$val) {
$store1 = Mage1Store::model()->find("store_id = {$mage1StoreId}");
if ($store1) {
$store2 = Mage2Store::model()->find("code = '{$store1->code}'");
if ($store2) {
$id = $store2->store_id;
}
} else {
$id = $mage1StoreId;
}
//save to cache for later
Yii::app()->cache->set($cacheId, $id, 86400);
// one day
} else {
$id = $val;
}
}
}
return $id;
}
示例10: testSystemMethodSignature
public function testSystemMethodSignature()
{
$request = $this->encodeRequest('system.methodSignature', array('system.listMethods'));
$result = $this->server->setPayload($request)->serve();
$decoded = $this->decodeResponse($result);
$decoded = (array) $decoded;
$this->assertCount(1, $decoded);
$this->assertEquals('array', $decoded[0]);
$request = $this->encodeRequest('system.methodSignature', array('system.methodSignature'));
$result = $this->server->setPayload($request)->serve();
$decoded = $this->decodeResponse($result);
$decoded = (array) $decoded;
$this->assertCount(2, $decoded);
$this->assertEquals('array', $decoded[0]);
$this->assertEquals('string', $decoded[1]);
$method = \Comodojo\RpcServer\RpcMethod::create("test.sum", function ($params) {
$a = $params->get('a');
$b = $params->get('b');
return is_null($a) || is_null($b) ? 42 : intval($a) + intval($b);
})->setDescription("Sum two integers")->setReturnType('int')->addParameter('int', 'a')->addParameter('int', 'b')->addSignature()->setReturnType('int');
$result = $this->server->methods()->add($method);
$request = $this->encodeRequest('system.methodSignature', array('test.sum'));
$result = $this->server->setPayload($request)->serve();
$decoded = $this->decodeResponse($result);
$decoded = (array) $decoded;
$this->assertCount(2, $decoded);
$this->assertInternalType('array', $decoded[0]);
$this->assertInternalType('array', $decoded[1]);
$this->assertCount(3, $decoded[0]);
$this->assertCount(1, $decoded[1]);
}
示例11: getInstance
public static function getInstance($dbSetting = 'default')
{
if (is_null(static::$instance)) {
static::$instance = new static($dbSetting);
}
return static::$instance;
}
示例12: handle
/**
* The handler which sets all the values in the dynamic definition.
*
* @param String $class the Controller class name
* @param LaravelSwagger $LS the LaravelSwagger instance.
* @throws DynamicHandlerException
*/
public function handle($class, LaravelSwagger $LS)
{
/**
*************************************
* Default Behaviour *
*************************************
*
* Loops through all of the linked keys
*/
foreach ($this->method->keys() as $key) {
/** @var mixed $value the value associated with the specific key */
$value = ValueContainer::getValue($class, $key);
if (is_string($value)) {
//if its a string of a class
//if it is a model that has been registered.
if (is_subclass_of($value, Model::class) && $LS->hasModel($value)) {
$value = "#/definitions/{$value}";
}
}
//if there is no value then throw an exception
if (is_null($value)) {
throw new DynamicHandlerException("{$key} value is NULL");
}
$this->method->set($key, $value);
}
}
示例13: __construct
public function __construct($p_id = null)
{
if (!is_null($p_id)) {
$this->m_data['id'] = $p_id;
$this->fetch();
}
}
示例14: get_instance
static function get_instance()
{
if (is_null(static::$instance)) {
static::$instance = new self();
}
return static::$instance;
}
示例15: is
/**
* @param User $user
* @return bool
*/
public function is(User $user = null)
{
if (is_null($user)) {
return false;
}
return $this->username == $user->username;
}