Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:00:38+00:00 2026-05-23T15:00:38+00:00

The PHP reference manuals say that, when serializing an object, the methods will not

  • 0

The PHP reference manuals say that, when serializing an object, the methods will not be saved. (See http://www.php.net/manual/en/language.oop5.serialization.php, paragraph 1).

However, the first example given in the manual shows a method being serialised, then unserialised and used.

Isn’t this a contradiction? Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:00:39+00:00Added an answer on May 23, 2026 at 3:00 pm

    I must say, that I don’t see where a method is serialized in the first example. When serializing no methods are serialized, only the classname and the properties. You can see this, if you have a look at the serialized data

    $ser = serialize($object);
    var_dump($ser);
    

    You will notice, that there is no method mentioned. However, if you unserialize an object, its recreated by the classname. Or in other words: You will get a new object, but with the values you serialized before.

    Usually this is not as important as it sounds like, because usually the serialized/unserialized object should behave the same.

    // serialize 
    class A {
      public $a = null;
      public function test () {
        echo "Hello";
      }
    }
    $a = new A;
    echo $a->test(); // "Hello"
    $x = serialize($a);
    
    // unserialize (somewhere else)
    class A {
      public $a = null;
      public function test () {
        echo "World";
      }
    }
    $a = unserialize($x);
    echo $a->test(); // "World"
    

    Here the serializer uses a “wrong” class and the output is different, than the expected one. As long as you make sure there are no classname collisions you usually don’t need to think about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at http://www.php.net/manual/en/array.sorting.php as a reference. I'm trying to sort the $_POST by
http://www.plus2net.com/php_tutorial/array_checkbox.php the link is my reference in PHP i want to ask how can
I noticed that the PHP session_decode() function has an object type for PHP reference
It appears that in PHP objects are passed by reference. Even assignment operators do
As i am reading manual of php for array functions, i see that some
There is a function similar_text() in the PHP library. The documentation ( http://php.net/manual/en/function.similar-text.php )
I agree with the PHP Modifiers Reference in the 'm' modifier description that says:
In the PHP manual, the file operations reference an optional context (e.g. for copy
Possible Duplicate: Reference: Comparing PHP's print and echo Is there any major and fundamental
Are PHP variables passed by value or by reference?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.