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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:31:27+00:00 2026-06-09T16:31:27+00:00

I got an object (in PHP) and I can’t print the content. In debug-mode

  • 0

I got an object (in PHP) and I can’t print the content.
In debug-mode it’s like this:

stdClass Object
(
    [pre-selection] => 1
)

But I can’t print the ‘pre-selection’ because of the minus sign.

echo $object->pre-selection; //doens't work.

How can I print this out? 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-09T16:31:28+00:00Added an answer on June 9, 2026 at 4:31 pm

    You could try

    $object->{'pre-selection'};
    

    http://php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

    See also Example 2 of json_decode()

    Example #2 Accessing invalid object properties

    Accessing elements within an object that contain characters not
    permitted under PHP’s naming convention (e.g. the hyphen) can be
    accomplished by encapsulating the element name within braces and the
    apostrophe.

    <?php
    
    $json = '{"foo-bar": 12345}';
    
    $obj = json_decode($json);
    print $obj->{'foo-bar'}; // 12345
    
    ?>
    

    Update (thanks to salathe):

    Curly braces may also be used, to clearly delimit the property name. They are most useful when accessing values within a property that contains an array, when the property name is made of mulitple parts, or when the property name contains characters that are not otherwise valid

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

Sidebar

Related Questions

ive got an object that looks like this with print_r(): SimpleDOM Object ( [0]
I would like to ask about PHP clone / copy object to $this variable.
I've got an object with functions that throw errors, myObj = { ini:function(){ this.f();
Can PHP dissect its own syntax? For example, I'd like to write a function
I'm trying to make a PHP (5) object that can iterate through its properties,
I've got a rather large multidimensional stdClass Object being outputted from a json feed
I am trying to iterate through array of objects in PHP, but I can't
Hi Masters of Web Programing. I've got this code: <?PHP $db_user = 'user'; $db_pass
Does PHP 4.4.8 version support mysqli object-oriented style? I have made ready this project
I've got a PHP background, but I'm beginning to learn Objective-C, so that I

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.