Jump to content

Recommended Posts

Please bear with me, a newbie here.

 

I'm trying to implement these on php but after a long googling, still not able to get better information.

 

1. Procedural packages

  function(main(myVar)

  {

      var mylocalVar="I'm a variable";

      function(subA(){  expr....  };

      function(subB(){ expr...},

  }

  main("php")->subA()

 

    I can do this approach in other language but I'm not able to do it in php.. Any other equivalent solution?

 

2. How can I overwrite, append, insert, delete an existing modular function (like question 1).

    append -> means just add sub function to the existing function, and always become part of the function

    insert    -> you can insert a function in a collection of a function, (usage might be on re-ordering the action)

    delete  -> delete/disable a function in a collection of a function

 

      I'm trying to make my codes dynamic and flexible as much as possible so I can plug any function that I want.

 

Thank you in advance.

   

Link to comment
https://forums.phpfreaks.com/topic/233319-modular-function/
Share on other sites

PHP doesn't have the concept of a main function/method.  Essentially, whatever is in the outermost/global scope is main.

 

Your code would be written as:

 

function subA(/* argument list */)
{
   // function code
}

function subB(/* argument list */)
{
   // function code
}

$localVar = "I'm a local variable.";

subA(/* passed in parameters */);

 

You can 'insert' with include, but there's no functionality for deleting or appending functions.

Link to comment
https://forums.phpfreaks.com/topic/233319-modular-function/#findComment-1199997
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.