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 9152877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:09:43+00:00 2026-06-17T12:09:43+00:00

Could anyone please explain to me why the following line of code prints out

  • 0

Could anyone please explain to me why the following line of code prints out true?

$a = "string";

if(isset($a['error'])) echo true; else echo false;

When I do a function call, I return the expected data if it worked properly, or return array("error" => $error);

Then on receiving the returned data I check if isset($var[‘error’]) and if its not then I know I received some expected data.

I would also appreciate if you could advice me if this a good or bad way of handling data between function calls? And if there is a better “good practice” for this.

  • 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-17T12:09:45+00:00Added an answer on June 17, 2026 at 12:09 pm

    Well, this is some of PHP misbehaviors, which luckily has been fixed in some recent version.

    You can address a single character in a string using the same square braces used to address an array element.

    'error' evaluates to 0 and then you have got $a[0] which is set.

    to fix that you have to check if $a is array first

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

Sidebar

Related Questions

Could anyone please explain the following line of code, found on http://docs.openttd.org/ai__cargo_8cpp_source.html return (AICargo::TownEffect)::CargoSpec::Get(cargo_type)->town_effect;
Could anyone explain the following line please? RewriteRule ^(.*)$ /index.php/$1 [L]
Could anyone please explain what the following line in my xsd mean ? <xsd:include
I am new to scala. Could anyone please explain the following piece of code
Could anyone please explain why this code compiles : #include <stdio.h> #include <string.h> int
Could anyone please tell me why the following line about filter init method invocation
Could anyone please explain how can I check if String is null or empty?
Could anyone explain the following two lines please? RewriteEngine on RewriteRule ^(.*)-(.*)-(.*)$ index.php?page=$1&id=$2&im=$3 I
Could anyone please explain what and how this code below is doing/working? RoleEnvironment.Chaning +=
Could anyone please explain with a sample...? How can I return an integer/String from

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.