Topic: OOP program: PHP code like J2ME code.

PHP code:

<?php
Main::startApp();
/*
*入口类
*/
class Main
{
    public static function startApp()
    {
        $lyj = new WapLyj();
        try {
            $lyj->test();//调用方法
        } catch(MyError $e) {
            echo $e->toString();//捕获错误
        }
    }
    public static function pauseApp() { }
    public static function distroyApp() { }
}
/*
*类一
*/
class WapLyj
{
    var $url = '';
    public function test()
    {
        if ($this->url == '')
            throw new MyError('变量$url未初始化值为“www.waplyj.in”');//抛出错误
        else
            echo '变量$url的值为'.$this->url;
    }
}
/*
*类二
*/
class MyError extends Exception
{
    var $msg = '';
    function __construct($msg)
    {
        $this->msg = $msg;
    }
    public function toString()
    {
        return $this->msg;
    }
}
?>
J2ME code:
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Display;
import javax.microedition.io.ConnectionNotFoundException;
/*
*入口类
*/
public class Main extends MIDlet
{
    protected void startApp()
    {
        WapLyj lyj = new WapLyj();
        try {
            lyj.test();//调用方法
        } catch(MyError e) {
            e.toString();//捕获错误
        }
    }
    protected void pauseApp() { }
    protected void destroyApp(boolean arg0) { }
}
/*
*类一
*/
class WapLyj
{
    String url = "";
    public void test() throws MyError
    {
        if (this.url == "")
            throw new MyError("变量url未初始化值为“www.waplyj.in”");//抛出错误
        else
        {
            try {
                new Main().platformRequest(this.url);
                } catch(ConnectionNotFoundException cnfe) { }
        }
    }
}
/*
*类二
*/
class MyError extends Exception
{
    String msg = "";
    public MyError(String msg)
    {
        this.msg = msg;
    }
    public String toString()
    {
        return this.msg;
    }
}
师父领进门,修行在个人。teach yourself

Re: OOP program: PHP code like J2ME code.

Nice comparison there. The only difference is that J2ME is a general purpose programming language, where as PHP is a scripting language.

Re: OOP program: PHP code like J2ME code.

J2ME(java2 Platform micro edition) it is generally used for client side scripting .and PHP is used for server side scripting.
PHP is designed for web development but they also use as general purpose programming language. where j2me is designed for embedded systems like SIM cards etc.hence we can write php code like  j2me but we include more user defined function,buit in functions   to get the  desired  output