-5

why ??

A PHP Error was encountered Severity: Notice

Message: Undefined property: stdClass::$users

Filename: views/user_view.php

Line Number: 10

Backtrace:

File: C:\xampp\htdocs\ci\application\views\user_view.php Line: 10 Function: _error_handler

File: C:\xampp\htdocs\ci\application\controllers\users.php Line: 7 Function: view

File: C:\xampp\htdocs\ci\index.php Line: 315 Function: require_once

Botje
  • 26,269
  • 3
  • 31
  • 41
  • Possible duplicate of ["Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – Alon Eitan May 07 '19 at 14:43
  • 1
    We are not able to answer your question if we can't see your code... – Kévin Bibollet May 07 '19 at 14:44

1 Answers1

1

You try to access a variable without it first being defined. If you define it first, you won't get an error.

<?php

$x = new stdClass();
$y = $x->z;   // gererates Notice in error_log


$x = new stdClass();
$x->z = 'assigned';    // now it is assigned
$y = $x->z;  // no error

// or you could make your own class
class Whatever
{
    public $z;
}

$x = new Whatever();
$y = $x->z;  // it's there whether a value has been assigned or not

Check it out here https://3v4l.org/hOThV

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39