Re: How to call different methods in one PHP file?

From: Paulus Magnus (paulus.magnus_at_loves-spam.com)
Date: 10/07/03


Date: Tue, 7 Oct 2003 11:10:52 +0000 (UTC)


"Bruce W...1" <bruce@noDirectEmail.com> wrote in message
news:3F824383.328B780@noDirectEmail.com...
> I'm a PHP newbie coming from experience with ASP.NET. I want to have a
separate
> PHP file to support each HTML PHP page. This would be the equivalent of
an
> ASP.NET code-behind file but using PHP.
>
> For one page to do a variety of different things I need to call different
> methods (or functions) in the PHP code file that is dedicated to this
purpose.
> How do you do this? How do you call just one method?
>
> Thanks for your help.

It isn't good programming style to use one PHP file per HTML page. Classes
should be based on functionality, as should PHP files. If all your pages
were to do with a membership system then you should have a Member class with
methods appropriate to that functionality.

If you've got a group of functions that perform similar actions you should
include them in a functions.member.inc.php file and include them where you
need them. You should group functions/methods by functionality rather than
per page as it will reduce the repetition element, imo.

Paulus



Relevant Pages

  • Re: Text file splitter, date/time field
    ... large text file into which I have copied PHP file after PHP file, ... You appear to want to write code in a language that you do not know. ... Perl's regular expression in the documentation that came with perl. ...
    (comp.lang.perl.misc)
  • [UNIX] YaPiG add_comment.php PHP Code Injection
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... YaPiG is "a simple but powerful web album ... * YaPiG version 0.92b (Latest downloaded files appear to be immune to PHP ... This Proof of Concept creates a php file that echoes a notice. ...
    (Securiteam)
  • php code compiles, produces good html output, but crashes when put through browser
    ... This is a postgresql/PHP running with PHP 5. ... The postgres part works fine, and the html that is generated is OK, but the .php file hangs when I run it through the browser. ... I need some basic debugging tools that I don't have to figure out what is going on. ...
    (php.general)
  • Re: I need help generating image along with other html
    ... I can now generate the background image on the same page as my form. ... for the php generating the picture below in hopes that someone can offer ... >>image along with other html. ... >>I obviously need to do more than just set the img src tag to the php file ...
    (alt.php)
  • Re: [PHP] Re: Opinions / Votes Needed
    ... hinting but it's just not enough to do what one needs. ... and don't try to change PHP to match your needs. ... it would simply be a case of exposing this functionality ... public static function staticMethod($a) { ...
    (php.general)