本文整理汇总了PHP中is_NULL函数的典型用法代码示例。如果您正苦于以下问题:PHP is_NULL函数的具体用法?PHP is_NULL怎么用?PHP is_NULL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_NULL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_session
function set_session($k, $v)
{
if ('' === $v || is_NULL($v)) {
unset($_SESSION($k));
} else {
$_SESSION[$k] = $v;
}
}
示例2: compileCoffee
/**
* Compile coffe script
*
* @param string
* @param bool|NULL
*
* @return string
*/
protected function compileCoffee($source, $bare = NULL)
{
if (is_NULL($bare)) {
$bare = $this->bare;
}
$cmd = $this->bin . ' -p -s' . ($bare ? ' -b' : '');
return $this->run($cmd, $source);
}
示例3: log_memory
/**
* Logs the memory usage of the provided variable, or entire script
*
* @param string $name Optional name used to group variables and scripts together
* @param mixed $variable Optional variable to log the memory usage of
*
* @return void
*/
public function log_memory($name = 'Memory usage at this point', $variable = NULL)
{
if (!is_NULL($variable)) {
$this->log_var_memory($name, $variable);
}
$log_item = array('data' => memory_get_usage(), 'name' => $name);
$this->_write('memory', $log_item);
}
示例4: __construct
/**
* Sets the configuration options for this object and sets the start time.
*
* Possible configuration options include:
* query_explain_callback - Callback used to explain queries. Follow format used by call_user_func
*
* @param array $config List of configuration options
* @param int $start_time Time to use as the start time of the profiler
*/
private function __construct(array $config = array(), $start_time = NULL)
{
if (is_NULL($start_time)) {
$start_time = microtime(TRUE);
}
$this->_start_time = $start_time;
$this->_config = $config;
$this->_console = new Profiler_Console();
}
示例5: __construct
public function __construct()
{
$gridfs_conf = Core::config('gridfs_servers');
$mongo = new \MongoClient($gridfs_conf['host'], $gridfs_conf['opt']);
$this->conn = $mongo->selectDB($gridfs_conf['db']['file']);
if (!is_NULL($gridfs_conf['user']) && !is_NULL($gridfs_conf['pwd'])) {
$this->conn->authenticate($gridfs_conf['user'], $gridfs_conf['pwd']);
}
}
示例6: set_session
function set_session($k, $v)
{
global $session_prefix;
if (is_NULL($v) || $v === '') {
unset($_SESSION[$session_prefix . $k]);
} else {
$_SESSION[$session_prefix . $k] = $v;
}
}
示例7: getlist
public function getlist($content = NULL, $data = NULL, $select = '*')
{
$this->db->select($select);
if (!is_NULL($this->offset)) {
$this->offset > 0 && ($this->offset = ($this->offset - 1) * $this->limit);
$this->db->offset($this->offset);
}
!is_NULL($this->limit) && $this->db->limit($this->limit);
if (!is_NULL($content) || !is_NULL($data)) {
$this->db->where($content, $data);
}
$this->db->order_by($this->order_by);
return $this->db->get($this->table_name)->result_array();
}
示例8: ConectarBD
/**
* Crea una nueva conexión con la base de datos, de existir, una conexión no hace nada
*
* @author jonathan_s_pisis@yahoo.com.mx
**/
static function ConectarBD()
{
if (!isset(self::$mysqli_obj) || is_NULL(self::$mysqli_obj)) {
$nombreDB = constant('NOMBRE_BASE_DATOS');
$usuario = constant('USUARIO');
$host = constant('HOST');
$clave = constant('PASSWORD');
self::$mysqli_obj = new mysqli($host, $usuario, $clave, $nombreDB);
/* check connection */
if (self::$mysqli_obj->connect_errno) {
printf("Connect failed: %s\n", self::$mysqli_obj->connect_error);
exit;
}
}
}
示例9: __construct
public function __construct($sourcePath, $logPath = NULL)
{
if (empty($sourcePath)) {
$this->srcPath = getcwd();
} else {
$this->srcPath = $sourcePath;
}
if (is_NULL($logPath)) {
$this->logPath = getcwd() . "/fo_integration.log";
echo "DB: logpath is:{$this->logPath}\n";
} else {
$this->logPath = $logPath;
echo "DB: logpath is:{$this->logPath}\n";
}
$this->LOGFD = fopen($this->logPath, 'a+');
if ($this->LOGFD === FALSE) {
$error = "Error! cannot open {$this->logPath}" . " File: " . __FILE__ . " on line: " . __LINE__;
throw new exception($error);
}
}
示例10: getSaltingInstance
/**
* Obtains a salting hashing method instance.
*
* This function will return an instance of a class that implements
* tx_saltedpasswords_abstract_salts.
*
* Use parameter NULL to reset the factory!
*
* @param string $saltedHash (optional) Salted hashed password to determine the type of used method from or NULL to reset the factory
* @param string $mode (optional) The TYPO3 mode (FE or BE) saltedpasswords shall be used for
* @return tx_saltedpasswords_abstract_salts an instance of salting hashing method object
*/
public static function getSaltingInstance($saltedHash = '', $mode = TYPO3_MODE)
{
// Creating new instance when
// * no instance existing
// * a salted hash given to determine salted hashing method from
// * a NULL parameter given to reset instance back to default method
if (!is_object(self::$instance) || !empty($saltedHash) || is_NULL($saltedHash)) {
// Determine method by checking the given hash
if (!empty($saltedHash)) {
$result = self::determineSaltingHashingMethod($saltedHash);
if (!$result) {
self::$instance = NULL;
}
} else {
$classNameToUse = \TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::getDefaultSaltingHashingMethod($mode);
$availableClasses = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/saltedpasswords']['saltMethods'];
self::$instance = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($availableClasses[$classNameToUse], 'tx_');
}
}
return self::$instance;
}
示例11: fillGroupForm
/**
* fillGroupForm($groupName, $user)
* \breif fill in the manage group fields
*
* @param string $groupName the name of the group to create
* @param string $user the user who will admin the group.
*
* @return NULL on success, string on error
*/
public function fillGroupForm($groupName, $user)
{
global $URL;
if (is_NULL($groupName)) {
$msg = "FATAL! no group name to set\n";
$this->fail($msg);
return $msg;
}
if (is_NULL($user)) {
$msg = "FATAL! no user name to set\n";
$this->fail($msg);
return $msg;
}
// make sure we are on the page
$page = $this->mybrowser->get("{$URL}?mod=group_manage");
$this->assertTrue($this->myassertText($page, '/Manage Group/'), "Did NOT find Title, 'Manage Group'");
$this->assertTrue($this->myassertText($page, '/Add a Group/'), "Did NOT find phrase, 'Add a Group'");
// set the fields
$groupNotSet = 'FATAL! Could Not set the groupname field';
if (!empty($groupName)) {
$this->assertTrue($this->mybrowser->setField('groupname', $groupName), $groupNotSet);
}
if (!empty($user)) {
$userNotSet = 'FATAL! Could Not set the userid field in select';
$this->assertTrue($this->mybrowser->setField('userid', $user), $userNotSet);
//return($userNotSet);
}
return NULL;
}
示例12: postfixEvaluate
/**
* Evaluate postfix notation
*
* @param array $tokens
* The list of tokens that make up the expression.
* @param array $vars
* The list of variables set previously.
*
* @return number
* The final result of the evaluation.
*/
private function postfixEvaluate($tokens, $vars = array())
{
if ($tokens == FALSE) {
return FALSE;
}
$stack = new EvalMathStack();
foreach ($tokens as $token) {
if (in_array($token, array('+', '-', '*', '/', '^'))) {
if (is_NULL($op2 = $stack->pop())) {
return $this->trigger(t('internal error'));
}
if (is_NULL($op1 = $stack->pop())) {
return $this->trigger(t('internal error'));
}
switch ($token) {
case '+':
$stack->push($op1 + $op2);
break;
case '-':
$stack->push($op1 - $op2);
break;
case '*':
$stack->push($op1 * $op2);
break;
case '/':
if ($op2 == 0) {
return $this->trigger(t('division by zero'));
}
$stack->push($op1 / $op2);
break;
case '^':
$stack->push(pow($op1, $op2));
break;
}
} elseif ($token == "_") {
$stack->push(-1 * $stack->pop());
} elseif (preg_match("/^([a-z]\\w*)\\(\$/", $token, $matches)) {
$fnn = $matches[1];
if (array_key_exists($fnn, $this->funcAliases)) {
$fnn = $this->funcAliases[$fnn];
}
if (array_key_exists($fnn, $this->funcBuildIn)) {
$argCount = $this->funcBuildIn[$fnn];
$args = array();
for ($i = $argCount; $i > 0; $i--) {
$arg = $stack->pop();
if (is_NULL($arg)) {
return $this->trigger(t('internal error: argument is null'));
}
$args[] = $arg;
$args = array_reverse($args);
}
$stack->push(call_user_func_array($fnn, $args));
} elseif (array_key_exists($fnn, $this->funcUser)) {
$args = array();
for ($i = count($this->funcUser[$fnn]['args']) - 1; $i >= 0; $i--) {
if (is_NULL($args[$this->funcUser[$fnn]['args'][$i]] = $stack->pop())) {
return $this->trigger(t('internal error: argument is null'));
}
}
$stack->push($this->postfixEvaluate($this->funcUser[$fnn]['func'], $args));
}
} else {
if (is_numeric($token)) {
$stack->push($token);
} elseif (array_key_exists($token, $this->variables)) {
$stack->push($this->variables[$token]);
} elseif (array_key_exists($token, $vars)) {
$stack->push($vars[$token]);
} else {
return $this->trigger(t('undefined variable "%token"', array('%token' => $token)));
}
}
}
if ($stack->getCount() != 1) {
return $this->trigger(t('internal error, stack not empty'));
}
return $stack->pop();
}
示例13: l
/**
* Method to return a language text element.
*
* @param string $itemName The language code for the item to be looked up
* @param string $modulename The module name that owns the string
* @param bool $default Default text
*
* @return string The language element
*/
protected function l($itemName, $modulename = NULL, $default = FALSE)
{
if (!defined('CHISIMBA_CONTROLLER_OBJLANGUAGE_CREATED')) {
define('CHISIMBA_CONTROLLER_OBJLANGUAGE_CREATED', TRUE);
$this->_objLanguage = $this->getObject('language', 'language');
}
$module = is_NULL($modulename) ? $this->moduleName : $modulename;
return $this->_objLanguage->languageText($itemName, $module, $default);
}
示例14: updateGoodsProduct
/**
* 更新商品的货品信息,对应操作5
* 干掉该商品的所有货品,再将平台上该商品的货品下载下来
*
* @param int $supplier_id
* @param int $supplier_goods_id
* @param int $command_id,更新列表的id
* @return array ,array(
* 'type' => array(
* $type_id => $type_name,
* $type_id => $type_name
* ),
* 'spec' => array(
* $spec_id => $spec_name,
* $spec_id => $spec_name
* ),
* 'brand' => array(
* 'add' => array(
* $brand_id => $brand_name,
* $brand_id => $brand_name,
* ),
* 'update' => array(
* $brand_id => $brand_name,
* $brand_id => $brand_name,
* )
* ),
* 'cat' => array(
* $cat_id => $cat_path,
* $cat_id => $cat_path
* ),
* 'locals' => array(
* 'local_type_id' => $local_type_id,
* 'local_spec_id' => $local_spec_id,
* 'local_brand_id' => $local_brand_id
* )
* )
*/
function updateGoodsProduct($supplier_id, $supplier_goods_id, $command_id)
{
$return = $this->preDownload($supplier_id, $supplier_goods_id, $command_id);
$local_goods_info = $this->db->selectrow("SELECT * FROM sdb_goods WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_goods_id=" . intval($supplier_goods_id));
$local_goods_id = $local_goods_info['goods_id'];
$local_product_info = $this->db->select("SELECT * FROM sdb_products WHERE goods_id=" . $local_goods_id);
/*
//先删除商品的所有货品(比较流氓,开会讨论结果)、sdb_goods_spec_index记录、sdb_supplier_pdtbn记录
$this->db->exec("DELETE FROM sdb_supplier_pdtbn WHERE local_bn IN (SELECT bn FROM sdb_products WHERE goods_id=".intval($local_goods_id).")");
$this->db->exec("DELETE FROM sdb_products WHERE goods_id=".intval($local_goods_id));
$this->db->exec("DELETE FROM sdb_goods_spec_index WHERE goods_id=".intval($local_goods_id));
*/
//根据货号获取可对应的本地product_id,将对应不到的product_id删除相关记录
$products = $this->api->getApiData('getProductsByGoodsID', API_VERSION, array('supplier_id' => $supplier_id, 'id' => $supplier_goods_id), true, true);
$tmp_product_id = array();
if (!empty($products)) {
foreach ($products as $v) {
$tmp = $this->db->selectrow("SELECT p.product_id FROM sdb_products AS p,sdb_supplier_pdtbn AS sp WHERE sp.source_bn='" . $v['bn'] . "' AND sp.supplier_id=" . intval($supplier_id) . " AND sp.local_bn=p.bn");
if ($tmp) {
$tmp_product_id[] = $tmp['product_id'];
}
}
}
foreach ($local_product_info as $v) {
if (!in_array($v['product_id'], $tmp_product_id)) {
$this->db->exec("DELETE FROM sdb_supplier_pdtbn WHERE local_bn='" . $v['bn'] . "'");
$this->db->exec("DELETE FROM sdb_products WHERE product_id=" . $v['product_id']);
$this->db->exec("DELETE FROM sdb_goods_spec_index WHERE product_id=" . $v['product_id']);
}
}
//删除商品的pdt_desc,spec_desc
$rs = $this->db->query("SELECT * FROM sdb_goods WHERE supplier_id=" . $supplier_id . " AND supplier_goods_id=" . $supplier_goods_id);
$sql = $this->db->GetUpdateSQL($rs, array('spec' => '', 'pdt_desc' => '', 'spec_desc' => ''));
if ($sql) {
$this->db->exec($sql);
}
$this->addProducts($supplier_id, $supplier_goods_id, $local_goods_id);
//获取货品的总库存数,取货品最小销售价作为商品销售价,最小重量作为商品重量
$product_info = $this->db->select("SELECT store,price,weight,cost FROM sdb_products WHERE goods_id=" . intval($local_goods_id));
$store = 0;
$price = NULL;
$weight = NULL;
$min_cost = NULL;
foreach ($product_info as $product) {
if (is_null($product['store']) || $product['store'] === '') {
$store = NULL;
} else {
if (!is_null($store)) {
$store += $product['store'];
}
}
if (is_null($price)) {
$price = empty($product['price']) ? 0.0 : $product['price'];
} else {
$price = min($price, $product['price']);
}
if (is_null($weight)) {
$weight = empty($product['weight']) ? 0.0 : $product['weight'];
} else {
$weight = min($weight, $product['weight']);
}
if (is_NULL($min_cost)) {
$min_cost = $product['cost'];
//.........这里部分代码省略.........
示例15: lista
/**
* Retorna uma lista de registros filtrados de acordo com os parâmetros
* @return array
*/
function lista($int_cod_compensado = NULL, $int_ref_cod_escola = NULL, $int_ref_ref_cod_instituicao = NULL, $int_ref_cod_servidor = NULL, $int_ref_usuario_exc = NULL, $int_ref_usuario_cad = NULL, $date_data_inicio_ini = NULL, $date_data_inicio_fim = NULL, $date_data_fim_ini = NULL, $date_data_fim_fim = NULL, $date_data_cadastro_ini = NULL, $date_data_cadastro_fim = NULL, $date_data_exclusao_ini = NULL, $date_data_exclusao_fim = NULL, $int_ativo = NULL)
{
$sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}";
$filtros = '';
$whereAnd = ' WHERE ';
if (is_numeric($int_cod_compensado)) {
$filtros .= "{$whereAnd} cod_compensado = '{$int_cod_compensado}'";
$whereAnd = ' AND ';
}
if (is_numeric($int_ref_cod_escola)) {
$filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
$whereAnd = ' AND ';
}
if (is_numeric($int_ref_ref_cod_instituicao)) {
$filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
$whereAnd = ' AND ';
}
if (is_numeric($int_ref_cod_servidor)) {
$filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
$whereAnd = ' AND ';
}
if (is_numeric($int_ref_usuario_exc)) {
$filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'";
$whereAnd = ' AND ';
}
if (is_numeric($int_ref_usuario_cad)) {
$filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_inicio_ini)) {
$filtros .= "{$whereAnd} data_inicio >= '{$date_data_inicio_ini}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_inicio_fim)) {
$filtros .= "{$whereAnd} data_inicio <= '{$date_data_inicio_fim}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_fim_ini)) {
$filtros .= "{$whereAnd} data_fim >= '{$date_data_fim_ini}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_fim_fim)) {
$filtros .= "{$whereAnd} data_fim <= '{$date_data_fim_fim}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_cadastro_ini)) {
$filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_cadastro_fim)) {
$filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_exclusao_ini)) {
$filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'";
$whereAnd = ' AND ';
}
if (is_string($date_data_exclusao_fim)) {
$filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'";
$whereAnd = ' AND ';
}
if (is_NULL($int_ativo) || $int_ativo) {
$filtros .= "{$whereAnd} ativo = '1'";
$whereAnd = ' AND ';
} else {
$filtros .= "{$whereAnd} ativo = '0'";
$whereAnd = ' AND ';
}
$db = new clsBanco();
$countCampos = count(explode(',', $this->_campos_lista));
$resultado = array();
$sql .= $filtros . $this->getOrderby() . $this->getLimite();
$this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}");
$db->Consulta($sql);
if ($countCampos > 1) {
while ($db->ProximoRegistro()) {
$tupla = $db->Tupla();
$tupla['_total'] = $this->_total;
$resultado[] = $tupla;
}
} else {
while ($db->ProximoRegistro()) {
$tupla = $db->Tupla();
$resultado[] = $tupla[$this->_campos_lista];
}
}
if (count($resultado)) {
return $resultado;
}
return FALSE;
}