From the isset() docs:
isset() will return FALSE if testing a variable that has been set to NULL.
Basically, isset() doesn't check for whether the variable is set at all, but whether it's set to anything but NULL.
Given that, what's the best way to actually check for the existence of a variable? I tried something like:
if(isset($v)...
Hi I am newish to php and I have created an update page for Content Management System. I have a file upload in this case a picture. I have other inputs that contain text and I can get them to populate my form and thats fine and works great because the user can see what has already been entered. But the file name for the photo can not hav...
Hi
I'm fairly new to PHP and am creating a website for my company. I am using some existing code that I have obtained but can't seem to make it work properly - any help would be much appreciated!
I have a variable, $id, which identifies the product category type to display on the page. I first need to check that the id variable has bee...
Hi,
I trying to understand if a isset is required during form processing when i check $_REQUEST["input_name"] if no value is passed it doesn't cry about it and php doesn't throw out an error if you are trying to access a array item which doesn't exist....i can use if($_REQUEST["input_name"])..
what about "empty" even in those cases i can...
Is there any speed difference between
if (isset($_POST['var']))
or
if ($_POST['var'])
And which is better or are they the same?
...
Hello,
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 outline my problem:
class test
{
int[] val1;
string val2;
static bool somefunction(test x, test y)
{
dosome...
I read somewhere that isset() function is that an empty string tests as TRUE, os isset() is not an effective way to validate text inputs and text boxes from a HTML form.
So you can use empty() to check that a user typed something....
Q1. Is it true that isset() function treat an empty string as TRUE?
Q2. Then in which situation I shou...
How would I add isset() and keep the empty() on my code below?
$pagesize = (!empty($_GET['pagesize'])) ? $_GET['pagesize'] : 20;
UPDATE:
I am just wanting to make sure php doesn't produce any notices or warnings
...
Is there any function available in PHP to check whether an array is empty or how can I do this without using loop?
For example: $b = array('key1' => '', 'key2' => '', 'key3' => '', 'key4' => '');
How can I check array $b contains empty values without using a loop?
...
I am writing a PHP script to add items to a shopping basket. My shopping basket table has fields for the userid, product id, session id, notes and a few others. Some of the fields can be blank. For example:
if someone isn't signed in, then I will store their session id in the table and, if they sign in, add their userid so I have a perm...
Imagine that I want to create an array from another array like this:
$array = array('bla' => $array2['bla'],
'bla2' => $array2['bla2'],
'foo' => $array2['foo'],
'Alternative Bar' => $array['bar'],
'bar' => $array2['bar']);
What is the best way to test either the $array2 ...
On a php file that many variables are received by $_REQUEST[] or $_POST[], and I have to check them in case the value is null with the function isset(), it is quite troublesome. Is there a better solution?
...
I mean... I "set" it to NULL. So isset($somethingNULL) == true?
...
I am getting this error in a PHP class...
Fatal error: Can't use method return
value in write context in
C:\webserver\htdocs\friendproject2\includes\classes\User.class.php
on line 35
Here is the troubled part.
if(isset($this->session->get('user_id')) && $this->session->get('user_id') != ''){
//run code
}
This code is...
Hi and thanks.
I have the following functions:
// NATION
var x, y, z;
function flag(nation,area)
{
x = nation;
this.nation=nation;
var el=document.getElementById("desc");
el.innerHTML='The region you have selected is <b>'+area+'</b>';
document.getElementById("flag").innerHTML='<img src="images/flags/'+nation+'.jpg">';
}
// SERVICE
func...
Probably an uber-newbie mistake. Here's my code:
<html>
<body>
<?php
if(isset($_POST["firstName"] && isset($_POST["lastName"]))){
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
echo $firstName;
}
else {
echo "First name was not written in, you suck!";
}
?>
</body>
I'm ge...
In PHP you can do if(isset($array['foo'])) { ... }. In Javascript you often use if(array.foo) { ... } to do the same, but this is not exactly the same statement. The condition will also evaluate to false if array.foo does exists but is null or false (and probably other values as well).
What is the perfect equivalent of PHP's isset in Ja...
class a
{
function __get($property){...}
}
$obj = new a();
var_dump(isset($obj->newproperty));
Seems the answer is nope but why?
...
Hello.
I am storing a session variable when a comment is inserted.. called user_message..
and i want to, when user_message, have been stored, THEN, show message on index.php
index.php is right now:
<div id="message">
<? echo $_SESSION["user_message"]; ?>
</div>
But you will need to refresh(f5) the site, to see the message AFTER its st...
How do i do in jquery, to check if there's anything in isset SESSION user_message, each 1 seconds, and if there is then display #box else dont..
thanks
...