Check if variable empty

0 votes

Code:

if ($user_id == NULL || $user_name == NULL || $user_logged == NULL) {
    $user_id = '-1';
    $user_name = NULL;
    $user_logged = NULL;
}
if ($user_admin == NULL) {
    $user_admin = NULL;
}
  1. Is there any shortest way to do it?
  2. And if I am right, it should be tested with is_null?
  3. Is It possible $user_id, $user_name and $user_logged to write in one line (maybe array?) without repeating NULL?
Jun 4 in PHP by Kichu
• 19,040 points
8 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How do check if a PHP session is empty?

Hii, I would use isset and empty: session_start(); if(isset($_SESSION['blah']) && !empty($_SESSION['blah'])) { ...READ MORE

answered Nov 9, 2020 in PHP by Niroj
• 82,720 points
4,095 views
0 votes
1 answer

How can I use PHP to check if a directory is empty?

Hello @kartik, It seems that you need scandir instead of ...READ MORE

answered Nov 10, 2020 in PHP by Niroj
• 82,720 points
4,161 views
0 votes
0 answers

PHP - If variable is not empty, echo some html code

I want to display some HTML code ...READ MORE

Jun 4 in PHP by Kichu
• 19,040 points
13 views
0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,720 points
2,860 views
0 votes
1 answer

How to check if a string is JSON or not?

Hello @kartik, Use JSON.parse function isJson(str) { ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,720 points
4,741 views
0 votes
1 answer

How to check if multiple array keys exists?

Hello @kartik, If you only have 2 keys ...READ MORE

answered Oct 27, 2020 in PHP by Niroj
• 82,720 points
1,616 views
0 votes
0 answers

How to check if a defined constant exists in PHP?

I am using fuelphp a PHP framework and I ...READ MORE

May 30 in PHP by Kichu
• 19,040 points
9 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
524 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
9,136 views
0 votes
1 answer

Failure uploading Image on AmazonS3 with PHP SDK

Try this, I took it out from ...READ MORE

answered May 4, 2018 in AWS by Cloud gunner
• 4,660 points
2,115 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP