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 7011963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:11:38+00:00 2026-05-27T22:11:38+00:00

When php returns a serialized string, does it only rely on the input value

  • 0

When php returns a serialized string, does it only rely on the input value or do outside sources (the environment) play any part at all?

The reason why I am asking this is, I am seeing some arrays that I believe to be identical get serialized slightly different per session.

I wrote this which demonstrates that they are always the same within the same session:

<?php
    $arr = array("something here", "foo" => "something else", "bar" => array( "nested" => "temp", 5232), 3434);

    $s = serialize($arr);

    for( $i = 1; $i <= 100; $i++ )
    {
        $s2 = serialize($arr);
        if( $s2 != $s )
        {
            echo "They are not always the same";
            break;
        }
        if($i == 100)
        {
            echo "They are always the same";
        }
    }
?>

So either there is something causing them to be created differently on different connections, or my arrays that appear to be identical are somehow not.

  • 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-27T22:11:39+00:00Added an answer on May 27, 2026 at 10:11 pm

    Serialized strings are human readable. They can be broken down as follows:

    a:2:{i:0;s:14:"something here";}
    

    The first letter is the datatype, array, the number is the length/size of the object. So next up you have an integer of 0 and then a string 14 characters in length. So now you can read the format can you see any differences?

    When I run your code on codepad it works as expected. So perhaps there is more at play here like in your actual code you are trying to serialize an object.

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

Sidebar

Related Questions

Is there something like serialize/unserialize PHP functions in jQuery? These functions return a string
If my PHP returns a array with 6 elements how would I access each
I have noticed that cURL in PHP returns different data when told to output
For some reason one installation of Moodle 1.9.3+ has a problem that file.php returns
I am using jQuery and Ajax, and my Ajax.php file returns the following field
I have a PHP page that returns a piece of HTML to set the
i have a php function which returns a random json encoded color <?php function
I have a RPC encoded PHP webservice that returns a simple soap envelope with
PHP's explode function returns an array of strings split on some provided substring. It
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new

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.