How-to articles, tricks, and solutions about OBJECT

Calling a function of a module by using its name (a string)

To call a function from a module by using its name as a string, you can use the importlib module.

Creating anonymous objects in php

In PHP, anonymous objects can be created using the new class syntax.

How do I check if an object has an attribute?

You can use the hasattr function to check if an object has an attribute.

How do I copy an object in Java?

There are several ways to copy an object in Java. Here are a few options:

How do I determine the size of an object in Python?

You can use the sys.getsizeof() function to determine the size of an object in bytes.

How do I print my Java object without getting "SomeType@2f92e0f4"?

To print a Java object in a more readable format, you can override the toString() method in your class.

How to cast an Object to an int

To cast an Object to an int in Java, you can use the intValue() method of the Integer class.

How to Convert a PHP Array to a JavaScript Array

In this tutorial, you can find a comprehensive guideline on how to convert a PHP array to JavaScript accurately. Just check out the options and examples.

How to convert a string to JSON object in PHP

You can use the json_decode function in PHP to convert a JSON string into a PHP object.

How to Convert DateTime to String in PHP

If you wish to manipulate with the DateTime object in PHP, then this snippet is for you. Here, you will learn how to correctly convert DateTime to string.

How to create new property dynamically

In PHP, you can create a new property for an object dynamically by using the magic method __set.

How to fix 'Creating default object from empty value' warning in PHP?

This error typically occurs when a variable is accessed as an object, but it has not been initialized or set to an object.

How to Fix the "Invalid Argument Supplied for Foreach()" PHP Error

The "invalid argument supplied for foreach()" is considered a common PHP error. With the help of this tutorial, you will figure out how to resolve it.

How to initialize an array of objects in Java

Here is an example of how you can initialize an array of objects in Java:

How to pass an object from one activity to another on Android

There are several ways you can pass an object from one activity to another on Android:

How to print instances of a class using print()?

To print instances of a class using the built-in print() function, you can define a __str__ method within the class.

Most efficient way to search for object in an array by a specific property's value

In PHP, you can use the built-in function array_filter() to filter the array by a specific property's value.

Null object in Python

In Python, the "null" object is called None.

PHP - warning - Undefined property: stdClass - fix?

It looks like you are trying to access a property of an object that has not been defined.

PHP : Remove object from array

Here is an example of how to remove an object from an array of objects in PHP:

PHP: Storing 'objects' inside the $_SESSION

In PHP, the $_SESSION superglobal is used to store data that needs to persist across multiple page requests.

Which Tag is Better to Use: <embed> or <object>

On this page, you will learn what is the difference between the HTML <embed> and <object> tags and which one is better to use. Read the snippet and find examples.

Why do Python classes inherit object?

In Python 3, all classes automatically inherit from the object class.