26561

PHP: Notice when error_reporting(E_ALL)

Question:

When I try to access info that is not presented in xml like so: $someInfo = $element->blabla->cats[0]->src; PHP shows notice like this: Notice: Trying to get property of non-object How would I settle the matter?

Answer1:

Just check if the specific element is set befor accessing data:

if(isset($element->blabla->cats[0]->src)){ $someInfo = $element->blabla->cats[0]->src; }

Recommend

  • +entityForName: could not locate an entity named 'Dogs' in this model.
  • Reset MySqli pointer?
  • Why newly created functions can not be found by SQL Server?
  • FPDF Fatal error: Allowed memory size of 33554432 bytes exhausted (PHP)
  • Sort a list by a custom order
  • The model item passed into the dictionary is of type A, but this dictionary requires a model item of
  • Pie-in-pie (Donut) charts
  • How can I update my Twitter status with Perl and only LWP::UserAgent?
  • How do I use SFSafariViewController with a dark theme like this user?
  • Plotting A Hyperboloid
  • Unable to set a breakpoint on main while debugging a program compiled with Rust 1.10 with GDB
  • Quick Question About Get and Set
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • How to view images from protected folder with php?
  • C: Incompatible pointer type initializing
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • Display images in Django
  • How to rebase a series of branches?
  • Resize panoramic image to fixed size
  • Controls, properties, events and timers running in design time
  • Updated Ionic CLI but shows previous version (Windows)
  • Importing jscolor library in angular 2
  • Upload files with Ajax and Jquery
  • Weird JavaScript statement, what does it mean?
  • Do I've to free mysql result after storing it?
  • Apache 2.4 - remove | delete | uninstall
  • A cron job substitute?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • json Serialization in asp
  • Benchmarking RAM performance - UWP and C#
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Django query for large number of relationships
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?