本文整理汇总了PHP中is_empty函数的典型用法代码示例。如果您正苦于以下问题:PHP is_empty函数的具体用法?PHP is_empty怎么用?PHP is_empty使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_empty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: valid_csrf_token
function valid_csrf_token($csrf_token)
{
if (is_empty($_SESSION["csrf_token"])) {
return false;
}
return $csrf_token == $_SESSION["csrf_token"];
}
示例2: login
public function login()
{
if (is_empty($this->post->user) || is_empty($this->post->password)) {
throw_exception("User and Password are required");
}
$options['user']['lvl2'] = "one_login";
$cod['user']['user'] = $this->post->user;
$cod['user']['password'] = $this->post->password;
$this->orm->connect();
$this->orm->read_data(array("user"), $options, $cod);
$user = $this->orm->get_objects("user");
#echo $user[0]->get('type');
$this->orm->close();
if (is_empty($user)) {
throw_exception("User or Password Incorrect");
} else {
$_SESSION['user']['id'] = $user[0]->get('id');
$_SESSION['user']['name'] = $user[0]->get('name');
$_SESSION['user']['user'] = $user[0]->get('user');
$_SESSION['user']['type'] = $user[0]->get('type');
$_SESSION['user']['email'] = $user[0]->get('email');
$this->session = $_SESSION;
$this->engine->assign('type_warning', 'success');
$this->engine->assign('msg_warning', "Welcome!");
$this->temp_aux = 'message.tpl';
}
}
示例3: agregar
public function agregar()
{
$parque = new parque($this->post);
if (is_empty($parque->get('codigo'))) {
throw_exception("Debe ingresar un codigo");
}
if ($parque->get("nivel") == "alto" || $parque->get("nivel") == "bajo") {
} else {
throw_exception("El nivel debe de ser alto o bajo");
}
if ($parque->get("municipio") == "medellin" || $parque->get("municipio") == "rionegro" || $parque->get("municipio") == "la estrella" || $parque->get(" municipio") == "copacabana" || $parque->get(" municipio") == "guatape") {
} else {
throw_exception("El municipio debe de ser medellin, rionegro, la estrella, copacabana o guatape");
}
print_r($parque);
$this->orm->connect();
$this->orm->insert_data("normal", $parque);
$this->orm->close();
settype($data, 'object');
$data->fecha = date("y-m-d");
$data->calificacion = 0;
$data->parque = $parque->get("codigo");
$calificacion = new calificacion($data);
$this->orm->connect();
$this->orm->insert_data("normal", $calificacion);
$this->orm->close();
$this->type_warning = "sucess";
$this->msg_warning = "parque agregado correctamente";
$this->temp_aux = 'message.tpl';
$this->engine->assign('type_warning', $this->type_warning);
$this->engine->assign('msg_warning', $this->msg_warning);
}
示例4: menu_affiliates
function menu_affiliates($args)
{
if (defined('NO_DB')) {
return;
}
global $objTPL, $objSQL;
$settings = array('limit' => doArgs('limit', 6, $args), 'perRow' => doArgs('limit', 2, $args));
//grab the table
$table = $objSQL->getTable('SELECT * FROM `$Paffiliates` WHERE active = 1 AND showOnMenu = 1 ORDER BY rand() LIMIT %d;', array($settings['limit']));
if ($table === NULL) {
return 'Error: Could not query Affiliates.';
}
if (is_empty($table)) {
return 'Error: No Affiliates in the database active.';
}
$return = NULL;
$counter = 1;
foreach ($table as $a) {
$title = secureMe($a['title']) . '
In: ' . $a['in'] . ' | Out: ' . $a['out'];
$return .= '<a href="/' . root() . 'affiliates.php?out&id=' . $a['id'] . '" title="' . $title . '" target="_blank" rel="nofollow"><img src="' . $a['img'] . '" alt="' . $title . '" /></a>';
if ($counter % $settings['perRow'] == 0) {
$return .= '<br />';
}
$counter++;
}
return '<center>' . $return . '</center>';
}
示例5: registrar
public function registrar()
{
$parque = new parque($this->post);
$this->engine->assign('codigo', $parque->get('codigo'));
$this->engine->assign('nombre', $parque->get('nombre'));
$this->engine->assign('municipio', $parque->get('municipio'));
$this->engine->assign('nivel', $parque->get('nivel'));
if (is_empty($parque->get('codigo'))) {
throw_exception("Debe ingresar un Codigo");
} elseif (!is_numeric($parque->get('codigo')) or $parque->get('codigo') < 0) {
throw_exception("Codigo invalido");
}
if (is_empty($parque->get('nombre'))) {
throw_exception("Debe ingresar un nombre");
}
if (is_empty($parque->get('municipio'))) {
throw_exception("Debe ingresar un municipio");
} elseif ($parque->get('municipio') != "Medellín" and $parque->get('municipio') != "Rionegro" and $parque->get('municipio') != "La Estrella" and $parque->get('municipio') != "Copacabana" and $parque->get('municipio') != "Guatapé") {
throw_exception("Municipio invalido, municipios validos: Medellín, Rionegro, La Estrella, Copacabana, Guatapé");
}
if (is_empty($parque->get('nivel'))) {
throw_exception("Debe ingresar un nivel");
} elseif ($parque->get('nivel') != "alto" and $parque->get('nivel') != "bajo") {
throw_exception("Nivel invalido, niveles validos: alto, bajo");
}
$this->orm->connect();
$this->orm->insert_data("normal", $parque);
$this->orm->close();
$this->type_warning = "Exito";
$this->msg_warning = "parque agregado correctamente";
$this->temp_aux = 'message.tpl';
$this->engine->assign('type_warning', $this->type_warning);
$this->engine->assign('msg_warning', $this->msg_warning);
}
示例6: validarCompletitud
public function validarCompletitud()
{
if (is_empty($this->get('nombre')) || is_empty($this->get('retribucion')) || is_empty($this->get('fechaPublicacion')) || is_empty($this->get('fechaFinalizacion')) || is_empty($this->get('empresa'))) {
return false;
}
return true;
}
示例7: add
public function add()
{
$parque = new parque($this->post);
if (is_empty($parque->get('nivel'))) {
throw_exception("Debe ingresar un nivel");
}
$parque = new parque($this->post);
if (is_empty($parque->get('nivel'))) {
throw_exception("Debe ingresar un municipio");
}
if ($parque->get('municipio') != "Medellín" && $parque->get('municipio') != "La estrella" && $parque->get('municipio') != "Rionegro" && $parque->get('municipio') != "Copacabana" && $parque->get('municipio') != "Guatapé") {
throw_exception("Municipio inválido");
}
if ($parque->get('nivel') != "alto" && $parque->get('nivel') != "bajo") {
throw_exception("Nivel inválido");
}
$this->orm->connect();
$this->orm->insert_data("normal", $parque);
$this->orm->close();
$this->type_warning = "sucess";
$this->msg_warning = "Parque registrado correctamente";
$this->temp_aux = 'message.tpl';
$this->engine->assign('type_warning', $this->type_warning);
$this->engine->assign('msg_warning', $this->msg_warning);
}
示例8: formFunctions
/**
* Test savingForm
* Test so a proper form is saved, with correct data.
* Also test if it is possible to enter incorrect data that might ruin something.
* @author Fredrik Andersson
* @small
* @test
*/
public function formFunctions()
{
// Create new user class
$a = new PP();
// Check if the object was created
$this->assertNotNull($a);
// Adding some variables into the form class PP
$a->student1 = "StudentName";
$this->assertEquals("StudentName", $a->student1);
//Test of the function test_num($data)
$this->assertEquals(1, test_num(1));
$this->assertEquals("-", test_num("-"));
$this->assertEquals("-", test_num(10));
//Test of the function test_input($data)
$this->assertEquals("123", test_input(" 123 "));
//trim() removes spaces before the first char and after the last one.
$this->assertEquals("123'hihi\ttab", test_input("123\\'hi\\hi\ttab"));
//stripslashes() removes all slashes exept proper slashes like \t and \n etc.
$this->assertEquals("& " < >", test_input("& \" < >"));
//htmlspecialchars() changes some special characters to code that html can handle.
//Test of the function is_empty($data)
$this->assertEquals(false, is_empty(array('apple', 'banana ', ' cranberry ')));
$this->assertEquals(false, is_empty(array('', '', '')));
$temp[10] = "something";
$this->assertEquals(false, is_empty($temp));
//Test of the function input_length()
$string128 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
$string129 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
$this->assertEquals($string128, input_length($string129));
//Test of the function length_one()
$this->assertEquals("1", length_one("12345"));
}
示例9: testIsEmpty
public function testIsEmpty()
{
$this->assertTrue(is_empty(null));
$this->assertTrue(is_empty(''));
$this->assertTrue(is_empty(0));
$this->assertFalse(is_empty('asd'));
}
示例10: validarCompletitud
public function validarCompletitud()
{
if (is_empty($this->get('nit')) || is_empty($this->get('nombre')) || is_empty($this->get('direccion')) || is_empty($this->get('telefono'))) {
return false;
}
return true;
}
示例11: validarIntereses
private function validarIntereses()
{
if (is_empty($this->post->interes)) {
return false;
}
return true;
}
示例12: execute
public function execute(Sabel_Bus $bus)
{
$response = $bus->get("response");
if ($response->isRedirected()) {
return;
}
$controller = $bus->get("controller");
$responses = $response->getResponses();
$contents = isset($responses["contents"]) ? $responses["contents"] : "";
$view = $this->setTemplateName($bus->get("view"), $response->getStatus(), $bus->get("destination")->getAction(), $bus->get("IS_AJAX_REQUEST") === true);
if (is_empty($contents)) {
if ($location = $view->getValidLocation()) {
$contents = $view->rendering($location, $responses);
} elseif (!$controller->isExecuted()) {
$response->getStatus()->setCode(Sabel_Response::NOT_FOUND);
if ($location = $view->getValidLocation("notFound")) {
$contents = $view->rendering($location, $responses);
} else {
$contents = "<h1>404 Not Found</h1>";
}
}
}
if ($bus->get("NO_LAYOUT")) {
$bus->set("result", $contents);
} else {
$layout = isset($responses["layout"]) ? $responses["layout"] : DEFAULT_LAYOUT_NAME;
if ($location = $view->getValidLocation($layout)) {
$responses["contentForLayout"] = $contents;
$bus->set("result", $view->rendering($location, $responses));
} else {
// no layout.
$bus->set("result", $contents);
}
}
}
示例13: JKY_buscar_cep
/**
* $.ajax({ method: buscar_cep, cep: 12345-678, state: '', city: '', street2: '', street1: '', district: '', country: '' })
*
* return: [ x...x, ..., x...x ]
*/
function JKY_buscar_cep($data)
{
$my_cep = fix_digits($data['zip']);
if (strlen($my_cep) == 8) {
if ($data['state'] == '' or $data['city'] == '' or $data['street2'] == '' or $data['street1'] == '' or $data['district'] == '') {
$my_curl = curl_init();
curl_setopt($my_curl, CURLOPT_URL, 'http://www.buscarcep.com.br/?&chave=146RwGh.Q3UM1x2871JTmxKemqLfYX/&formato=xml&cep=' . $my_cep);
curl_setopt($my_curl, CURLOPT_RETURNTRANSFER, 1);
$my_return = curl_exec($my_curl);
curl_close($my_curl);
if (!is_empty($my_return)) {
$my_cep = new SimpleXMLElement($my_return);
if ($my_cep->retorno->resultado == '1') {
$data['state'] = remover_acentos($my_cep->retorno->uf);
$data['city'] = remover_acentos($my_cep->retorno->cidade);
$data['street2'] = remover_acentos($my_cep->retorno->bairro);
$data['street1'] = remover_acentos($my_cep->retorno->tipo_logradouro . ' ' . $my_cep->retorno->logradouro);
$data['district'] = remover_acentos($my_cep->retorno->ibge_municipio_verificador);
}
}
}
$data['country'] = get_control_value('System Defaults', 'Company Country');
}
$data['status'] = 'ok';
return $data;
}
示例14: getContent
public function getContent()
{
if (is_empty($this->path)) {
return "";
} else {
return file_get_contents($this->path);
}
}
示例15: select_cards_player
function select_cards_player($player)
{
$player = select_with_request_string("cards", "player", array("player", "cards", "game"), array(), array("game" => game, "player" => $player));
if (!is_empty($player[0]["cards"])) {
return $player[0]["cards"];
}
return 0;
}