name);" method; and finally output the deleted data."/> name);" method; and finally output the deleted data.">

Home  >  Article  >  Backend Development  >  How to delete attributes of an object in php

How to delete attributes of an object in php

藏色散人
藏色散人Original
2020-08-31 09:11:014594browse

php method to delete object attributes: first create a PHP sample file; then delete the object attributes through the "unset($user->name);" method; and finally output the deleted data.

How to delete attributes of an object in php

Recommended: "PHP Video Tutorial"

PHP Deleting Object Properties

The code is as follows:

<?php
define(&#39;CLI_SCRIPT&#39;, true);
$user = new stdClass();
$user->id = 1;
$user->name = &#39;tony&#39;;
$user->age = 23;
var_dump($user);
unset($user->name);
var_dump($user);

The above is the detailed content of How to delete attributes of an object in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn