isset Questions

2

Solved

Is there a shorthand way to assign a variable to something if it doesn't exist in PHP? if(!isset($var) { $var = ""; } I'd like to do something like $var = $var | "";
Ephraim asked 3/9, 2013 at 23:52

6

Solved

I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something } and if ($_POST['Submit']) { //do something } It seems to me that if the $_POST['Subm...
Pastorate asked 17/3, 2010 at 6:36

2

Solved

How to check if array variable $a = array('a'=>1, 'c'=>null); is set and is null. function check($array, $key) { if (isset($array[$key])) { if (is_null($array[$key])) { echo $key . ' i...
Illinium asked 20/7, 2013 at 21:56

2

Solved

How to check if a multidimensional array item is set in JS? w[1][2] = new Array; w[1][2][1] = new Array; w[1][2][1][1] = 10; w[1][2][1][2] = 20; w[1][2][1][4] = 30; How to check if w[1][2][1][3]...
Haydeehayden asked 2/6, 2013 at 14:2

5

Solved

class a { function __get($property){...} } $obj = new a(); var_dump(isset($obj->newproperty)); Seems the answer is nope but why?
Transliterate asked 21/2, 2010 at 18:48

2

Solved

Possible Duplicate: Any more concise way to set default values? Is there a built-in php function like the following: function isset_get($array, $key, $default = null) { return isset...
Semple asked 29/12, 2012 at 23:46

5

Solved

For example, if I implement some simple object caching, which method is faster? 1. return isset($cache[$cls]) ? $cache[$cls] : $cache[$cls] = new $cls; 2. return @$cache[$cls] ?: $cache[$cls] = n...
Tuberculin asked 4/10, 2012 at 18:39

3

Solved

I've noticed that frequently people simply write <?php if($_SESSION['username']) {...} ?> while I have been using: <?php if(isset($_SESSION['username'])) {...} ?> Could someone...
Laurice asked 7/5, 2012 at 23:50

7

Solved

I know this is a dumb question and I guess it must have been asked before. However I am unable to find an answer to my question. Here is some sample code (which of course does not compile) to outl...
Zoroaster asked 28/7, 2009 at 17:41

2

Solved

I have some strange issue with isset() function in PHP. Let me show... . <?php $aTestArray = array( 'index' => array( 'index' => 'Główna' ), 'dodaj' => 'Dodaj ogłoszenie', ); var...
Pejsach asked 3/12, 2011 at 23:12

8

Solved

I'm trying to check that user's submitted data, from $_POST, has at least the same elements that my passed array has. I'm doing it because I will use those elements later by calling $_POST['element...
Baseburner asked 8/10, 2011 at 16:37

2

Solved

$a = NULL; $c = 1; var_dump(isset($a)); // bool(false) var_dump(isset($b)); // bool(false) var_dump(isset($c)); // bool(true) How can I distinguish $a, which exists but has a value of NULL, from ...
Oversupply asked 6/10, 2011 at 12:50

2

Solved

class A { public static $foo = 42; } $class = 'A'; $attribute = 'foo'; var_dump(isset($class::$attribute)); //gives bool(false) How can i checkt, of this static attribute exists in this class?...
Podite asked 24/4, 2011 at 16:37

3

Solved

I have a simple associative array. $a = array("a"=>"b", "c"=>"d"); I want to check if the key "1" exists in the array, e.g. isset($a["1"]); This string is being treated as an integer, s...
Procedure asked 9/1, 2011 at 4:27

2

Solved

Is there a way to check if an object has any fields? For example, I have a soap server I am querying using a soap client and if I call a get method, I am either returned an object containing fields...
Boomkin asked 10/8, 2010 at 14:44

2

Solved

How do you test to see if sessions are on. This is not the way... session_start(); if(isset($_SESSION)) { echo "sessions ON<br>"; } else{ echo "sessions OFF<br>"; } session_destroy(...
Inappreciative asked 28/7, 2010 at 21:42

1

Solved

I have an upload form with a file to be uploaded. The issue I have is that even when no file is uploaded the if(isset($_FILES)) OR if(!empty($_FILES)) still passes as successful: $_FILES = $HTTP_P...
Rox asked 30/3, 2010 at 22:2

5

Solved

Is there any speed difference between if (isset($_POST['var'])) or if ($_POST['var']) And which is better or are they the same?
Didymous asked 10/5, 2009 at 0:22

© 2022 - 2024 — McMap. All rights reserved.