F
F
frigolov2015-10-03 14:24:05
PHP
frigolov, 2015-10-03 14:24:05

How to declare that a variable is an object?

To indicate that a variable is an array - they write $var = array();
, but how to indicate that this is an object?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2015-10-03
@frigolov

php.net/manual/en/language.types.object.php

<?php
$obj = (object) 'ciao';
echo $obj->scalar;  // выведет 'ciao'
?>

<?php
$object = new stdClass();
?>

A
Alexey Tsarapkin, 2015-10-03
@Dreamka

<?php
$object = new ClassName();
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question