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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:40:19+00:00 2026-06-12T18:40:19+00:00

I’m using the Google Map API V3 sending it the Lat/Lng and it returns

  • 0

I’m using the Google Map API V3 sending it the Lat/Lng and it returns the full address. I’m parsing the address that’s returned by using the Object. It works for many addresses but for some of them it is generating the PHP error of about the property being a non-object:

PHP Notice:  Trying to get property of non-object in get5.php on line 47
PHP Notice:  Trying to get property of non-object in get5.php on line 48
PHP Notice:  Trying to get property of non-object in get5.php on line 49

Here are the lines of code for 47-49:

$city_google_api = $country->AdministrativeArea->Locality->LocalityName;
$state_google_api = $country->AdministrativeArea->AdministrativeAreaName;
$zip_code_google_api = $country->AdministrativeArea->Locality->PostalCode->PostalCodeNumber;

I would like to debug this further, but I don’t know which record this is causing these messages regarding the property of non-object. Is there a way to trap on the error or check for “property of non-object” so that I can dump the variables? I don’t want to dump this for each record because that’s too much output. In general, I would like to know if there is a way to trap errors to dump variables? Thanks!

  • 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-12T18:40:20+00:00Added an answer on June 12, 2026 at 6:40 pm

    Take:

    $city_google_api = $country->AdministrativeArea->Locality->LocalityName;
    

    and temporarily re-write it:

    $area            = $country->AdministrativeArea;
    $locality        = $area->Locality;
    $city_google_api = $locality->LocalityName;
    

    Do the same for the other three lines and, presto, the line number in the error will tell you precisely where the problem is.

    Divide and conquer — your debug technique friend.


    You could also program defensively from the start so that the error is not just better reported, but “caught” at runtime:

    if (!is_object($country))
       throw SomeException();
    
    $area = $country->AdministrativeArea;
    
    if (!is_object($area))
       throw SomeException();
    
    $locality = $area->Locality;
    
    if (!is_object($locality))
       throw SomeException();
    
    $city_google_api = $locality->LocalityName;
    

    or go further and examine the actual type of each object. This is usually overkill, though — once you have fixed your code, you will know what type each variable has, and the original three lines will suffice.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.