jessecasimsiman Posted April 11, 2011 Share Posted April 11, 2011 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 More sharing options...
KevinM1 Posted April 11, 2011 Share Posted April 11, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.