[How to] set different memory_limit value only in a file

4 replies
Hi guys,

in WHM >> PHP Configuration Editor (php.ini) >> the memory_limit are set to 30M, so the server no need too high resource, and to prevent poorly written scripts for eating up all available memory on a server

I want a file only, lets say some.php, that already trusted of course, get higher memory_limit more than set in php.ini


is there any way to do that?
#file #memorylimit #set
  • Profile picture of the author Havenhood
    This modification is server dependent, but here you go...

    (Place at the beginning of the file... just after the open tag.)

    ini_set("memory_limit","60M");

    Change the value 60M to whatever...


    P.S. At the end of the file, you may want to add this... ini_restore("memory_limit");
    Signature

    --= -Spazzle- =--

    {{ DiscussionBoard.errors[3406715].message }}
    • Profile picture of the author basketmen
      Originally Posted by Havenhood View Post

      This modification is server dependent, but here you go...

      (Place at the beginning of the file... just after the open tag.)

      ini_set("memory_limit","60M");

      Change the value 60M to whatever...


      P.S. At the end of the file, you may want to add this... ini_restore("memory_limit");
      so it is looks like this? :



      PHP Code:
      ini_set("memory_limit","60M");
      <?php




      ?>
      ini_restore("memory_limit");
      {{ DiscussionBoard.errors[3406903].message }}
    • Profile picture of the author jminkler
      Originally Posted by Havenhood View Post

      This modification is server dependent, but here you go...

      (Place at the beginning of the file... just after the open tag.)

      ini_set("memory_limit","60M");

      Change the value 60M to whatever...


      P.S. At the end of the file, you may want to add this... ini_restore("memory_limit");
      On shared hosting this value may be capped, or disabled all together.
      {{ DiscussionBoard.errors[3407069].message }}
      • Profile picture of the author Havenhood

        <?php
        ini_set("memory_limit","60M");



        ini_restore("memory_limit");
        ?>

        Signature

        --= -Spazzle- =--

        {{ DiscussionBoard.errors[3407314].message }}

Trending Topics