I am managing a website with a custom framework, developed by some programmers who are no longer working in out company. In some parts of the code I saw this:
$class = 'PagesControl';
$obj = clone new $class();
What is this thing supposed to do? Why would you clone an object created like that?
Closing a file is performed using the fclose() function. fclose(fptr);
close(): This function helps to close an existing file. get(): This function helps to read a single character from the file. put(): This function helps to write a single character in the file.
The close() function shall deallocate the file descriptor indicated by fildes. To deallocate means to make the file descriptor available for return by subsequent calls to open() or other functions that allocate file descriptors.
Using return is the easiest way to exit a function. You can use return by itself or even return a value.
No, it is meaningless.
It should be:
$class = 'PagesControl';
$obj = new $class();
And if $class is fixed, then it should be $obj = new PagesControl();
Maybe they have some strange setup in the __clone()
method that need to be called just after instatiation but it would be pretty pointless. If the class PagesControl
has no __clone()
method, just take off the clone
, otherwise put the code that is present in the __clone()
method inside the __construct()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With