Answers.Body: <p>You can</p>
  
  <pre class="lang-twig prettyprint-override"><code>&lt;pre&gt;
  {{ dump(myObject) }}
  &lt;/pre&gt;
  </code></pre>
  
  <p>And see it's type and attributes. You can as well use <code>{{ dump(Object.getAttributes) }}</code> with nearly everything in Yii2. If it's just about getting to know what object you currently have this function will be your friend once you know how to use it. Another approach would be much simpler yet more powerful: take a look at the source code or enable intellisense for your IDE and let your IDE show you everything </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T22:50:13.743Z
Answers.Text: Any idea why it outputs a number instead of doing dump by default?
Answers.UserDisplayName: BBaysinger
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T23:02:55.107Z
Answers.Text: In PHP there is `toString` method for objects so when you echo them, they'll be converted into a string. This is useful for entries (so they show their title) or for sections (to show their handle). So when you know what you are doing this might be a handy trick to shorten your syntax. The downside is: when you don't know what object you exactly have you might get in trouble because you don't even know you have an object. For example all redactor field values are objects as well and when you do `{{ entry.text }}` they'll output their stored html. Same goes for single selects.
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T21:48:23.890Z
Answers.LastActivityDate: 2020-04-01T06:09:04.793Z
Answers.LastEditDate: 2020-04-01T06:09:04.793Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I was looking for a way to show all fields/properties of a given object, and came across this useful tidbit: <a href="https://craftcms.stackexchange.com/questions/2926/how-to-display-all-fields-belonging-to-current-entry">How to display all fields belonging to current entry?</a></p>
  
  <p>I'm new to Craft/Twig and didn't actually know what type of object I'm trying to output properties of. I'm not sure when I output the object with <code>{{ mysteryObject }}</code> it outputs a number. That doesn't seem useful.</p>
  
  <p>When I do the loop like in the <a href="https://craftcms.stackexchange.com/questions/2926/how-to-display-all-fields-belonging-to-current-entry">question I referenced above</a> like:</p>
  
  <pre><code>    {% for prop in mysteryObject.getFields() %}
          {# get the field Model from the fieldId #}
          {% set field = craft.fields.getFieldById(mysteryObject.fieldId) %}
          {# print the field handle and the field content  #}
          {{ field.handle }}
          :
          {{ entry.getContent()[field.handle] }}
      {% endfor %}
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Calling unknown method: craft\elements\MatrixBlock::getFields()</p>
  </blockquote>
  
  <p>Cool, so now I know my object is a <code>MatrixBlock</code>, but this makes me wonder how I would go about inspecting the properties of just any object, like you can in JavaScript, without knowing what the object is.</p>
  
Tags: <templating><craft3>
Title: Display all fields without knowing object type?
ThreadText: # Display all fields without knowing object type?
  
  (Asked by: username_0 on 2019-03-19)
  
  I was looking for a way to show all fields/properties of a given object, and came across this useful tidbit: [How to display all fields belonging to current entry?](https://craftcms.stackexchange.com/questions/2926/how-to-display-all-fields-belonging-to-current-entry)
  
  I'm new to Craft/Twig and didn't actually know what type of object I'm trying to output properties of. I'm not sure when I output the object with `{{ mysteryObject }}` it outputs a number. That doesn't seem useful.
  
  When I do the loop like in the [question I referenced above](https://craftcms.stackexchange.com/questions/2926/how-to-display-all-fields-belonging-to-current-entry) like:
  
  ```
      {% for prop in mysteryObject.getFields() %}
          {# get the field Model from the fieldId #}
          {% set field = craft.fields.getFieldById(mysteryObject.fieldId) %}
          {# print the field handle and the field content  #}
          {{ field.handle }}
          :
          {{ entry.getContent()[field.handle] }}
      {% endfor %}
  
  ```
  
  I get the error:
  
  > Calling unknown method: craft\elements\MatrixBlock::getFields()
  
  Cool, so now I know my object is a `MatrixBlock`, but this makes me wonder how I would go about inspecting the properties of just any object, like you can in JavaScript, without knowing what the object is.
  
  **Tags:** templating, craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-19. Score: 2 | Accepted answer
  
  You can
  
  ```twig
  <pre>
  {{ dump(myObject) }}
  </pre>
  
  ```
  
  And see it's type and attributes. You can as well use `{{ dump(Object.getAttributes) }}` with nearly everything in Yii2. If it's just about getting to know what object you currently have this function will be your friend once you know how to use it. Another approach would be much simpler yet more powerful: take a look at the source code or enable intellisense for your IDE and let your IDE show you everything
  
  > **Comments:**
  > **username_0**: Any idea why it outputs a number instead of doing dump by default?  
  > **username_1**: In PHP there is `toString` method for objects so when you echo them, they'll be converted into a string. This is useful for entries (so they show their title) or for sections (to show their handle). So when you know what you are doing this might be a handy trick to shorten your syntax. The downside is: when you don't know what object you exactly have you might get in trouble because you don't even know you have an object. For example all redactor field values are objects as well and when you do `{{ entry.text }}` they'll output their stored html. Same goes for single selects.  
  
  ---
  
  