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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:55:28+00:00 2026-06-17T10:55:28+00:00

Possible Duplicate: In PHP how can I access a :private array in an object?

  • 0

Possible Duplicate:
In PHP how can I access a “:private” array in an object?

I am not sure if there is a right way to do this or if this is completely unacceptable technique.

I am using PHP and I am in a situation where a script is given an object, it does not have access to the objects Class and many of the properties are protected (see below).

Is it possible to “hack” (bad choice of words) the object manually to amend property values on the fly?
Not sure of a way to do this or if there is a way by converting one way and then back again.

object(__PHP_Incomplete_Class)#3 (16) {


["__PHP_Incomplete_Class_Name"]=>
  string(28) "Zend_Controller_Request_Http"
  ["_paramSources":protected]=>
  array(2) {
    [0]=>
    string(4) "_GET"
    [1]=>
    string(5) "_POST"
  }
  ["_requestUri":protected]=>
  string(13) "/?mod=mainnav"
  ["_baseUrl":protected]=>
  NULL
  ["_basePath":protected]=>
  NULL
  ["_pathInfo":protected]=>
  string(0) ""
  ["_params":protected]=>
  array(0) {
  }
  ["_rawBody":protected]=>
  NULL
  ["_aliases":protected]=>
  array(0) {
  }
  ["_dispatched":protected]=>
  bool(false)
  ["_module":protected]=>
  NULL
  ["_moduleKey":protected]=>
  string(6) "module"
  ["_controller":protected]=>
  NULL
  ["_controllerKey":protected]=>
  string(10) "controller"
  ["_action":protected]=>
  NULL
  ["_actionKey":protected]=>
  string(6) "action"
}
  • 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-17T10:55:30+00:00Added an answer on June 17, 2026 at 10:55 am

    Ended up using a more simple technique to do this.
    I have the Object serialized into a string. So I simply replaced the current value (which I always have) with the new value using preg_replace.

    There is some regex which will find the variable name and then I could change its value (so doesn’t require knowing the value) but I hadn’t been able to complete that yet (and I do have the current value).

    $objectA = serialize($request);
    $current_url = '\?mod=mainnav';
    $new_url = 'newpage';
    $objectB = preg_replace('/'.$current_url.'/', $new_url, $objectA);
    
    //check the new object
    var_dump('<pre>');
    var_dump(unserialize($objectB));
    var_dump('</pre>');
    

    Using Reflections is probably the better technique most of the time, but for what I needed here I felt this was an simple and fast way to do it plus keeps all other object properties.

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

Sidebar

Related Questions

Possible Duplicate: Dirt-simple PHP templates… can this work without eval ? Let's say I
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: PHP PDO: Can I bind an array to an IN() condition? I
Possible Duplicate: Any way to access array directly after method call? In C# and
Possible Duplicate: Can php variable hold harmfull code safely? Let's say I have array
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved
Possible Duplicate: PHP: How to chain method on a newly created object? I can
Possible Duplicate: Access array returned by a function in php I have a function
Possible Duplicate: PHP: Is there a command that can delete the contents of a
Possible Duplicate: PHP pagination class are there any PHP/Class libraries that i can utilize

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.