search

Home  >  Q&A  >  body text

PHP delete object properties

How to delete an attribute of an object in php?

高洛峰高洛峰2736 days ago2066

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-06-30 09:57:21

    unset

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

    reply
    0
  • Cancelreply