Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9271859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:43:57+00:00 2026-06-18T15:43:57+00:00

To my understanding, in oppose to javascript which offers the convenient if (var) {}

  • 0

To my understanding, in oppose to javascript which offers the convenient if (var) {}, even if var doesn’t exist, in PHP you have to use if (isset(var)) {}, or if (isset(var) && var) {}.

Today I’ve stumbled upon a login tutorial that seems to be from a reliable source, in which isset is not used:

if(!$_SESSION['id']):

[From the linked page, demo.php section, line 15]

On my local sever, this line breaks when $_SESSION['id'] is not set, which is, IMHO, an expected behaviour. $_SESSION['id'] is not defined prior to this line.

Is there a mysterious way to avoid the annoying isset() check?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:43:59+00:00Added an answer on June 18, 2026 at 3:43 pm

    Your application doesn’t “break”, because it is just a notice and yes: You should always test the existence of array keys, if you are unsure, whether they exists, or not.

    $defaults = array('id' => null);
    $session = array_merge($defaults, $_SESSION);
    

    Now you can be sure, that $session has a key id.

    However, your can suppress warnings and notices with @

    if (!@$_SESSION['id']) { /* .. */ }
    

    But usually if you ever touch the @ key:

    • You have a really good reason
    • You did something wrong 🙂

    In a clean application you need @ only in some very rare cases.

    A word at the end: Never use values from outside without validation!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel I have a pretty decent understanding of closures, how to use them,
My understanding of regex and working with strings in php is poor at best
My understanding is that when using && as an mathematical operation in Java, if
My understanding of C# says (thanks to Jeff Richter & Jon Skeet) that assignment
My understanding is that you're typically supposed to use xor with GetHashCode() to produce
My understanding is that Google Analytics (the tool I'd normally use for website analytics)
My understanding is, that .NET doesn't really 'do' config files for DLLs - only
I generally oppose extension since it creates a very strong connection between classes, which
Understanding that if someone had JavaScript disabled the site would not work then is
Some of the complicated sample code I've seen doesn't use storyboards, for example the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.