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

  • SEARCH
  • Home
  • 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 9284051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:47:29+00:00 2026-06-18T18:47:29+00:00

I have 3 source files as follows: first one is source_class.php class MacMini {

  • 0

I have 3 source files as follows:

first one is source_class.php

class MacMini
{
    public $memory = "16 Gigabytes";
    public $cpu = "Intel Core i7 @ 2.6GHz";
    public $HD = "1TB @ 5200 rpms";
    public function mem()
    {
        return $this->memory;
    }
    public function centralPU()
    {
        return $this->cpu;
    }
    public function hard_drive()
    {
        return $this->HD;
    }
}

///////////////////////////////////////////////////

second one is serialize.php

include "source_class.php";
$myMini = new MacMini;
$myMini->cpu = "Intel Core i7 @ 3.4GHz";
$serialized = serialize($myMini);
file_put_contents("store", $serialized);

//////////////////////////////////////////////

third one is unserialize.php

include "source_class.php";
$data = file_get_contents("store");
$unserialized = unserialize($data);

$myMini = new MacMini;
echo $myMini->cpu;

it produces the following output:
“Intel Core i7 @ 2.6GHz”

Why, if the property of the cpu was changed in the serialize.php file, is it not reflected in the unserialization? I checked the raw data contents of the serialized file, “store” and the cpu property is reflected in the serialized file but when it’s unserialized in unserialize.php the property change is not reflected. Why is that? Can anyone explain?

  • 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-06-18T18:47:30+00:00Added an answer on June 18, 2026 at 6:47 pm

    The problem is that you create a new $myMini object and output the cpu properity of this newly created object. The serialization/ unserialization doesn’t make sense this way.

    Change unserialize.php to :

    include "source_class.php";
    $data = file_get_contents("store");
    $myMini = unserialize($data);
    
    echo $myMini->cpu;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three source files in a folder. I simply want to compile them
I am writing a kernel module in which i have 3 source files and
Say you have 100s of source files (.c or .cpp) files, and you want
All source files seem to have compiled fine. However, since I achieved that, I
I have a number of source files I want to agglomerate into a .a
I have an application which loads up c# source files dynamically and runs them
I have to build some C source files using Visual Studio (currently using VS2008)
I have a Util package with source files in three seperate directories, defined like
I have a set of Java 5 source files with old-style Doclet tags, comments
I have created a new branch and did svn import of the source files

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.