How to delete attributes of an object in php

藏色散人
Release: 2023-03-05 13:38:01
Original
4600 people have browsed it

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);
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template