Home > Blockchain >  How to change or covert stdclass object name?
How to change or covert stdclass object name?

Time:10-26

I tried to find answers for this question but couldn't find any solution. I'm getting dizzy with this simple thing, so I ask here.

My current output (when var_dump the result):

object(stdClass)[8]
public 'somedata' => string 'somedata' (length=32)

I need an output like this (when var_dump the result):

object(Config\App)[7]
  public 'somedata' => string 'somedata' (length=32)

CodePudding user response:

I just found the answer after a few hours of research that resolves the issue. I will post it here as reference.

Resource: https://blog.sonarsource.com/php-object-injection

Using:

<?php
$object = new stdClass();
$object->data = "Some data!";
$cached = serialize($object);

Output:

O:8:"stdClass":1:{s:4:"data";s:10:"Some data!";}

Resolving by unserialize the php object

$object = unserialize('O:10:"Config\App":1:{s:4:"data";s:10:"Some data!";}');

Since there is no one can provide answer for an alternative way of "convert/change stdclass object name to another name" I will mark this as answer

  • Related