multiple functions and pages and proper methods in storing them for performance2019 Community Moderator ElectionPreferred method to store PHP arrays (json_encode vs serialize)SEO friendly URLS HTACCESS PHPMathematical equation to link pagesusing ignore_user_abort and set_time_limit(0)With PHP include can you define the including page in the included page?How to use http_referer if form field and php script are at the same page?PHP 404 response and redirectHow can I clear my php session data correctly?How to realize the wordpress permalink function on an homemade php websiteJquery Ajax Post data on multiple pages running on background

What problems would a superhuman have whose skin is constantly hot?

Why does the negative sign arise in this thermodynamic relation?

Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?

Could you please stop shuffling the deck and play already?

Distinction between apt-cache and dpkg -l

Does this video of collapsing warehouse shelves show a real incident?

How strictly should I take "Candidates must be local"?

Latex does not go to next line

Makefile strange variable substitution

Definition of Statistic

What are some noteworthy "mic-drop" moments in math?

Good for you! in Russian

Can I pump my MTB tire to max (55 psi / 380 kPa) without the tube inside bursting?

Should I take out a loan for a friend to invest on my behalf?

What are actual Tesla M60 models used by AWS?

List elements digit difference sort

How can I get players to stop ignoring or overlooking the plot hooks I'm giving them?

Vocabulary for giving just numbers, not a full answer

Signed and unsigned numbers

Contract Factories

Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?

Virginia employer terminated employee and wants signing bonus returned

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

How to draw cubes in a 3 dimensional plane



multiple functions and pages and proper methods in storing them for performance



2019 Community Moderator ElectionPreferred method to store PHP arrays (json_encode vs serialize)SEO friendly URLS HTACCESS PHPMathematical equation to link pagesusing ignore_user_abort and set_time_limit(0)With PHP include can you define the including page in the included page?How to use http_referer if form field and php script are at the same page?PHP 404 response and redirectHow can I clear my php session data correctly?How to realize the wordpress permalink function on an homemade php websiteJquery Ajax Post data on multiple pages running on background










0















i have too many made-functions nearly 30 of them in a file named functions.php has them ordered like this



<?php
function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
------
function f30(...)......


and i have 10 pages in my website that has this in the head of it include("functions.php");



but for each page it uses a limit number of functions like



page1 = f1(), f2(), f3(), f4(), f5()
page2 = f1(), f3(), f5(), f7(), f9()
page3 = f1(), f2(), f4(), f8(), f9()
page4 = f1(), f6()
---------
page10 = f1(), f2(), f3(), f14(), f22(), f24(), f29()


so i thought including all 30 functions for every page is an over use for it so i thought of this



1- a page for each function included separatly for each function like



page1

include("f1.php");
include("f2.php");
include("f3.php");
include("f4.php");
include("f5.php");


2- a page contains all functions for every single page like



page1_functions.php

function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
function f5(...)......


and included once in page1 using include("page1_functions.php");




the cons i see for each method is



all-in-one as (functions.php): unnecessary function included that may affect the performance in someway



page for each function (f1.php, f2.php,...): too many includes that may affect performance in someway



page of functions for each page (page1_functions.php, page2_functions.php): functions may be repeated multiple times and take more space and may affect the performance in someway



so i can't decide what is the best method to follow










share|improve this question







New contributor




Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3





    Seems like time to look at OOP (instead of procedural code), Classes instead of functions and PSR autoloading.

    – ArtisticPhoenix
    Mar 7 at 6:50












  • I don't think you need to worry too much about the performance impact. They won't impact execution speed if they aren't called, and I doubt the impact on memory consumption would be significant enough to warrant refactoring your code. If you find an arrangement that is more logical or organized then go ahead and do it, but not for the sake of performance gain.

    – Stephen
    Mar 7 at 7:19











  • i will keep all of this in mind

    – Joe Doe
    Mar 7 at 8:02











  • Classes or OOP (Object Oriented Programing), is a big topic. But it lets you group like functions together in a state full way. Once you add PSR-4 autoloading, the class files are magically loaded when you instantiate a new object (which is what a class give you). And you get inheritance.. Really it's too big a topic to cover.

    – ArtisticPhoenix
    Mar 7 at 8:03
















0















i have too many made-functions nearly 30 of them in a file named functions.php has them ordered like this



<?php
function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
------
function f30(...)......


and i have 10 pages in my website that has this in the head of it include("functions.php");



but for each page it uses a limit number of functions like



page1 = f1(), f2(), f3(), f4(), f5()
page2 = f1(), f3(), f5(), f7(), f9()
page3 = f1(), f2(), f4(), f8(), f9()
page4 = f1(), f6()
---------
page10 = f1(), f2(), f3(), f14(), f22(), f24(), f29()


so i thought including all 30 functions for every page is an over use for it so i thought of this



1- a page for each function included separatly for each function like



page1

include("f1.php");
include("f2.php");
include("f3.php");
include("f4.php");
include("f5.php");


2- a page contains all functions for every single page like



page1_functions.php

function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
function f5(...)......


and included once in page1 using include("page1_functions.php");




the cons i see for each method is



all-in-one as (functions.php): unnecessary function included that may affect the performance in someway



page for each function (f1.php, f2.php,...): too many includes that may affect performance in someway



page of functions for each page (page1_functions.php, page2_functions.php): functions may be repeated multiple times and take more space and may affect the performance in someway



so i can't decide what is the best method to follow










share|improve this question







New contributor




Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3





    Seems like time to look at OOP (instead of procedural code), Classes instead of functions and PSR autoloading.

    – ArtisticPhoenix
    Mar 7 at 6:50












  • I don't think you need to worry too much about the performance impact. They won't impact execution speed if they aren't called, and I doubt the impact on memory consumption would be significant enough to warrant refactoring your code. If you find an arrangement that is more logical or organized then go ahead and do it, but not for the sake of performance gain.

    – Stephen
    Mar 7 at 7:19











  • i will keep all of this in mind

    – Joe Doe
    Mar 7 at 8:02











  • Classes or OOP (Object Oriented Programing), is a big topic. But it lets you group like functions together in a state full way. Once you add PSR-4 autoloading, the class files are magically loaded when you instantiate a new object (which is what a class give you). And you get inheritance.. Really it's too big a topic to cover.

    – ArtisticPhoenix
    Mar 7 at 8:03














0












0








0


1






i have too many made-functions nearly 30 of them in a file named functions.php has them ordered like this



<?php
function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
------
function f30(...)......


and i have 10 pages in my website that has this in the head of it include("functions.php");



but for each page it uses a limit number of functions like



page1 = f1(), f2(), f3(), f4(), f5()
page2 = f1(), f3(), f5(), f7(), f9()
page3 = f1(), f2(), f4(), f8(), f9()
page4 = f1(), f6()
---------
page10 = f1(), f2(), f3(), f14(), f22(), f24(), f29()


so i thought including all 30 functions for every page is an over use for it so i thought of this



1- a page for each function included separatly for each function like



page1

include("f1.php");
include("f2.php");
include("f3.php");
include("f4.php");
include("f5.php");


2- a page contains all functions for every single page like



page1_functions.php

function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
function f5(...)......


and included once in page1 using include("page1_functions.php");




the cons i see for each method is



all-in-one as (functions.php): unnecessary function included that may affect the performance in someway



page for each function (f1.php, f2.php,...): too many includes that may affect performance in someway



page of functions for each page (page1_functions.php, page2_functions.php): functions may be repeated multiple times and take more space and may affect the performance in someway



so i can't decide what is the best method to follow










share|improve this question







New contributor




Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












i have too many made-functions nearly 30 of them in a file named functions.php has them ordered like this



<?php
function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
------
function f30(...)......


and i have 10 pages in my website that has this in the head of it include("functions.php");



but for each page it uses a limit number of functions like



page1 = f1(), f2(), f3(), f4(), f5()
page2 = f1(), f3(), f5(), f7(), f9()
page3 = f1(), f2(), f4(), f8(), f9()
page4 = f1(), f6()
---------
page10 = f1(), f2(), f3(), f14(), f22(), f24(), f29()


so i thought including all 30 functions for every page is an over use for it so i thought of this



1- a page for each function included separatly for each function like



page1

include("f1.php");
include("f2.php");
include("f3.php");
include("f4.php");
include("f5.php");


2- a page contains all functions for every single page like



page1_functions.php

function f1(...)......
function f2(...)......
function f3(...)......
function f4(...)......
function f5(...)......


and included once in page1 using include("page1_functions.php");




the cons i see for each method is



all-in-one as (functions.php): unnecessary function included that may affect the performance in someway



page for each function (f1.php, f2.php,...): too many includes that may affect performance in someway



page of functions for each page (page1_functions.php, page2_functions.php): functions may be repeated multiple times and take more space and may affect the performance in someway



so i can't decide what is the best method to follow







php performance






share|improve this question







New contributor




Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 7 at 6:46









Joe DoeJoe Doe

124




124




New contributor




Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Joe Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 3





    Seems like time to look at OOP (instead of procedural code), Classes instead of functions and PSR autoloading.

    – ArtisticPhoenix
    Mar 7 at 6:50












  • I don't think you need to worry too much about the performance impact. They won't impact execution speed if they aren't called, and I doubt the impact on memory consumption would be significant enough to warrant refactoring your code. If you find an arrangement that is more logical or organized then go ahead and do it, but not for the sake of performance gain.

    – Stephen
    Mar 7 at 7:19











  • i will keep all of this in mind

    – Joe Doe
    Mar 7 at 8:02











  • Classes or OOP (Object Oriented Programing), is a big topic. But it lets you group like functions together in a state full way. Once you add PSR-4 autoloading, the class files are magically loaded when you instantiate a new object (which is what a class give you). And you get inheritance.. Really it's too big a topic to cover.

    – ArtisticPhoenix
    Mar 7 at 8:03













  • 3





    Seems like time to look at OOP (instead of procedural code), Classes instead of functions and PSR autoloading.

    – ArtisticPhoenix
    Mar 7 at 6:50












  • I don't think you need to worry too much about the performance impact. They won't impact execution speed if they aren't called, and I doubt the impact on memory consumption would be significant enough to warrant refactoring your code. If you find an arrangement that is more logical or organized then go ahead and do it, but not for the sake of performance gain.

    – Stephen
    Mar 7 at 7:19











  • i will keep all of this in mind

    – Joe Doe
    Mar 7 at 8:02











  • Classes or OOP (Object Oriented Programing), is a big topic. But it lets you group like functions together in a state full way. Once you add PSR-4 autoloading, the class files are magically loaded when you instantiate a new object (which is what a class give you). And you get inheritance.. Really it's too big a topic to cover.

    – ArtisticPhoenix
    Mar 7 at 8:03








3




3





Seems like time to look at OOP (instead of procedural code), Classes instead of functions and PSR autoloading.

– ArtisticPhoenix
Mar 7 at 6:50






Seems like time to look at OOP (instead of procedural code), Classes instead of functions and PSR autoloading.

– ArtisticPhoenix
Mar 7 at 6:50














I don't think you need to worry too much about the performance impact. They won't impact execution speed if they aren't called, and I doubt the impact on memory consumption would be significant enough to warrant refactoring your code. If you find an arrangement that is more logical or organized then go ahead and do it, but not for the sake of performance gain.

– Stephen
Mar 7 at 7:19





I don't think you need to worry too much about the performance impact. They won't impact execution speed if they aren't called, and I doubt the impact on memory consumption would be significant enough to warrant refactoring your code. If you find an arrangement that is more logical or organized then go ahead and do it, but not for the sake of performance gain.

– Stephen
Mar 7 at 7:19













i will keep all of this in mind

– Joe Doe
Mar 7 at 8:02





i will keep all of this in mind

– Joe Doe
Mar 7 at 8:02













Classes or OOP (Object Oriented Programing), is a big topic. But it lets you group like functions together in a state full way. Once you add PSR-4 autoloading, the class files are magically loaded when you instantiate a new object (which is what a class give you). And you get inheritance.. Really it's too big a topic to cover.

– ArtisticPhoenix
Mar 7 at 8:03






Classes or OOP (Object Oriented Programing), is a big topic. But it lets you group like functions together in a state full way. Once you add PSR-4 autoloading, the class files are magically loaded when you instantiate a new object (which is what a class give you). And you get inheritance.. Really it's too big a topic to cover.

– ArtisticPhoenix
Mar 7 at 8:03













1 Answer
1






active

oldest

votes


















0














This is too big a topic to really cover but.



Here is a simple example say you have these functions:



function f1(...)......
function f2(...)......
function f3(...)......

function f4(...)......

function f5(...)......


You always need the first 3 and not the second too.



 //Foo.php
class Foo
function f1(...)......
function f2(...)......
function f3(...)......


//FooBar.php
require_once 'Foo.php'
class FooBar extends Foo
function f4(...)......


//FooBiz.php
require_once 'Foo.php'
class FooBiz extends Foo
function f5(...)......



So now if I use Foo



 require_once 'Foo.php';
$Foo = new Foo;
$Foo->f1();


So now if I use FooBar



 require_once 'FooBar.php'; //which has its own require_once 'Foo.php';
$FooBar = new FooBar;
$FooBar->f1(); //from extends foo
$FooBar->f4();


And so on. FooBiz would be the same as FooBar except that it does not have f4() instead it has all of Foo and f5(). FooBar has all of Foo and f4(). You can layer it as much as you like, you can even override methods from the "parent" class etc...



There is a lot more to it then this, but this is the basics. Plus because these are "methods" inside a class you can make a totally different class with the same method names without naming conflicts.



Then with autoloading you don't even need the require_once statements.



This is an autoloader I made, the defacto standard is to use Composer and it's autoloader, but you can play around with this one and get an idea of how they work.



https://github.com/ArtisticPhoenix/Autoloader



There are some naming conventions and stuff to consider, but if you are not using namespaces, as long as the Autoloader.php is in the same folder as the class files it should be able to load them using just:



require_once 'Autoloader.php';

$Autoloader = evoautoloaderAutoloader::getInstance();

// require_once 'Foo.php'; - no longer needed, nor is the ones in the class files
$foo = new Foo;


The idea behind this is to load the class file (which is a collection of functions and other stuff) on demand when they are called with new.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Joe Doe is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037623%2fmultiple-functions-and-pages-and-proper-methods-in-storing-them-for-performance%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This is too big a topic to really cover but.



    Here is a simple example say you have these functions:



    function f1(...)......
    function f2(...)......
    function f3(...)......

    function f4(...)......

    function f5(...)......


    You always need the first 3 and not the second too.



     //Foo.php
    class Foo
    function f1(...)......
    function f2(...)......
    function f3(...)......


    //FooBar.php
    require_once 'Foo.php'
    class FooBar extends Foo
    function f4(...)......


    //FooBiz.php
    require_once 'Foo.php'
    class FooBiz extends Foo
    function f5(...)......



    So now if I use Foo



     require_once 'Foo.php';
    $Foo = new Foo;
    $Foo->f1();


    So now if I use FooBar



     require_once 'FooBar.php'; //which has its own require_once 'Foo.php';
    $FooBar = new FooBar;
    $FooBar->f1(); //from extends foo
    $FooBar->f4();


    And so on. FooBiz would be the same as FooBar except that it does not have f4() instead it has all of Foo and f5(). FooBar has all of Foo and f4(). You can layer it as much as you like, you can even override methods from the "parent" class etc...



    There is a lot more to it then this, but this is the basics. Plus because these are "methods" inside a class you can make a totally different class with the same method names without naming conflicts.



    Then with autoloading you don't even need the require_once statements.



    This is an autoloader I made, the defacto standard is to use Composer and it's autoloader, but you can play around with this one and get an idea of how they work.



    https://github.com/ArtisticPhoenix/Autoloader



    There are some naming conventions and stuff to consider, but if you are not using namespaces, as long as the Autoloader.php is in the same folder as the class files it should be able to load them using just:



    require_once 'Autoloader.php';

    $Autoloader = evoautoloaderAutoloader::getInstance();

    // require_once 'Foo.php'; - no longer needed, nor is the ones in the class files
    $foo = new Foo;


    The idea behind this is to load the class file (which is a collection of functions and other stuff) on demand when they are called with new.






    share|improve this answer





























      0














      This is too big a topic to really cover but.



      Here is a simple example say you have these functions:



      function f1(...)......
      function f2(...)......
      function f3(...)......

      function f4(...)......

      function f5(...)......


      You always need the first 3 and not the second too.



       //Foo.php
      class Foo
      function f1(...)......
      function f2(...)......
      function f3(...)......


      //FooBar.php
      require_once 'Foo.php'
      class FooBar extends Foo
      function f4(...)......


      //FooBiz.php
      require_once 'Foo.php'
      class FooBiz extends Foo
      function f5(...)......



      So now if I use Foo



       require_once 'Foo.php';
      $Foo = new Foo;
      $Foo->f1();


      So now if I use FooBar



       require_once 'FooBar.php'; //which has its own require_once 'Foo.php';
      $FooBar = new FooBar;
      $FooBar->f1(); //from extends foo
      $FooBar->f4();


      And so on. FooBiz would be the same as FooBar except that it does not have f4() instead it has all of Foo and f5(). FooBar has all of Foo and f4(). You can layer it as much as you like, you can even override methods from the "parent" class etc...



      There is a lot more to it then this, but this is the basics. Plus because these are "methods" inside a class you can make a totally different class with the same method names without naming conflicts.



      Then with autoloading you don't even need the require_once statements.



      This is an autoloader I made, the defacto standard is to use Composer and it's autoloader, but you can play around with this one and get an idea of how they work.



      https://github.com/ArtisticPhoenix/Autoloader



      There are some naming conventions and stuff to consider, but if you are not using namespaces, as long as the Autoloader.php is in the same folder as the class files it should be able to load them using just:



      require_once 'Autoloader.php';

      $Autoloader = evoautoloaderAutoloader::getInstance();

      // require_once 'Foo.php'; - no longer needed, nor is the ones in the class files
      $foo = new Foo;


      The idea behind this is to load the class file (which is a collection of functions and other stuff) on demand when they are called with new.






      share|improve this answer



























        0












        0








        0







        This is too big a topic to really cover but.



        Here is a simple example say you have these functions:



        function f1(...)......
        function f2(...)......
        function f3(...)......

        function f4(...)......

        function f5(...)......


        You always need the first 3 and not the second too.



         //Foo.php
        class Foo
        function f1(...)......
        function f2(...)......
        function f3(...)......


        //FooBar.php
        require_once 'Foo.php'
        class FooBar extends Foo
        function f4(...)......


        //FooBiz.php
        require_once 'Foo.php'
        class FooBiz extends Foo
        function f5(...)......



        So now if I use Foo



         require_once 'Foo.php';
        $Foo = new Foo;
        $Foo->f1();


        So now if I use FooBar



         require_once 'FooBar.php'; //which has its own require_once 'Foo.php';
        $FooBar = new FooBar;
        $FooBar->f1(); //from extends foo
        $FooBar->f4();


        And so on. FooBiz would be the same as FooBar except that it does not have f4() instead it has all of Foo and f5(). FooBar has all of Foo and f4(). You can layer it as much as you like, you can even override methods from the "parent" class etc...



        There is a lot more to it then this, but this is the basics. Plus because these are "methods" inside a class you can make a totally different class with the same method names without naming conflicts.



        Then with autoloading you don't even need the require_once statements.



        This is an autoloader I made, the defacto standard is to use Composer and it's autoloader, but you can play around with this one and get an idea of how they work.



        https://github.com/ArtisticPhoenix/Autoloader



        There are some naming conventions and stuff to consider, but if you are not using namespaces, as long as the Autoloader.php is in the same folder as the class files it should be able to load them using just:



        require_once 'Autoloader.php';

        $Autoloader = evoautoloaderAutoloader::getInstance();

        // require_once 'Foo.php'; - no longer needed, nor is the ones in the class files
        $foo = new Foo;


        The idea behind this is to load the class file (which is a collection of functions and other stuff) on demand when they are called with new.






        share|improve this answer















        This is too big a topic to really cover but.



        Here is a simple example say you have these functions:



        function f1(...)......
        function f2(...)......
        function f3(...)......

        function f4(...)......

        function f5(...)......


        You always need the first 3 and not the second too.



         //Foo.php
        class Foo
        function f1(...)......
        function f2(...)......
        function f3(...)......


        //FooBar.php
        require_once 'Foo.php'
        class FooBar extends Foo
        function f4(...)......


        //FooBiz.php
        require_once 'Foo.php'
        class FooBiz extends Foo
        function f5(...)......



        So now if I use Foo



         require_once 'Foo.php';
        $Foo = new Foo;
        $Foo->f1();


        So now if I use FooBar



         require_once 'FooBar.php'; //which has its own require_once 'Foo.php';
        $FooBar = new FooBar;
        $FooBar->f1(); //from extends foo
        $FooBar->f4();


        And so on. FooBiz would be the same as FooBar except that it does not have f4() instead it has all of Foo and f5(). FooBar has all of Foo and f4(). You can layer it as much as you like, you can even override methods from the "parent" class etc...



        There is a lot more to it then this, but this is the basics. Plus because these are "methods" inside a class you can make a totally different class with the same method names without naming conflicts.



        Then with autoloading you don't even need the require_once statements.



        This is an autoloader I made, the defacto standard is to use Composer and it's autoloader, but you can play around with this one and get an idea of how they work.



        https://github.com/ArtisticPhoenix/Autoloader



        There are some naming conventions and stuff to consider, but if you are not using namespaces, as long as the Autoloader.php is in the same folder as the class files it should be able to load them using just:



        require_once 'Autoloader.php';

        $Autoloader = evoautoloaderAutoloader::getInstance();

        // require_once 'Foo.php'; - no longer needed, nor is the ones in the class files
        $foo = new Foo;


        The idea behind this is to load the class file (which is a collection of functions and other stuff) on demand when they are called with new.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 7 at 8:25

























        answered Mar 7 at 8:14









        ArtisticPhoenixArtisticPhoenix

        17.4k11225




        17.4k11225






















            Joe Doe is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Joe Doe is a new contributor. Be nice, and check out our Code of Conduct.












            Joe Doe is a new contributor. Be nice, and check out our Code of Conduct.











            Joe Doe is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037623%2fmultiple-functions-and-pages-and-proper-methods-in-storing-them-for-performance%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme