php / php/doc-en

Example #2 empty() on String Offsets

Open
#2,929 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

The Example #2 empty() on String Offsets has an issue.

The line with the code var_dump(empty($expected_array_got_string['some_key']));

Is not the better way to exemplify.

$expected_array_got_string is not actually an array, but a string or another type that when accessed like an array ($expected_array_got_string['some_key']), results in NULL, which is considered empty.

The empty function is explained in this documentation only with references like if a "variable is considered empty if it does not exist or if its value equals false"

Please, complete the documentation with the reference for NULL values.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PHP empty() documentation and inspect Example #2, especially the var_dump(empty($expected_array_got_string['some_key'])) line. Clarify why the expression evaluates as empty when array-style access produces NULL, and document NULL among the values considered empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.