Jump to content

How to define common functions?


kks_krishna

Recommended Posts

(Using php5) You could define your util class as containing static methods.

 

<?php

  class util {
    static public foo() {
      echo "Hello from foo!\n";
    }
  }

  util::foo(); // now you can call foo() without the need to instantiate the util class.

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.