PHP Object new method for Class, Memory Leak and U

2019-04-18 00:05发布

问题:

I have Created following class in flie index.class.php :-

<?php
class index{
        public function loadTitle() {
            $title = "Welcome to My Website";
            return $title;
        }
    }
?>

and now, I am using it like below in my index.php file

    <?php
        require_once("index.class.php");
        $obj = new index();
        echo $obj->loadTitle();
    ?>

, now my question is Page will become heavy with lots of article and images, and i will expect 1500-2500 user every day in it.

Do, i need to also unset memory, i know PHP has its own garbage collector, but following URL scares me out :- www.google.com/search?q=php+memory+leak+with+new

and i saw few question in stackoverflow that it does consumes memory, and certain people have suggested to use unset function, but i am not sure, how to do it..

This is my try.. :-

Do i need to only call

<?php
    unset($obj); // At the end of the page, or where i will no more be using this object.
?>

or i have to set NULL value too.

<?php
    $obj = NULL;
    unset($obj);
?>

is above code fine for releasing memory, or do i need to do something else too.. Please suggest and teach me. It will be very helpful.

Thanks