How can I display an alert/ message in object-oriented PHP?

Currently I have used JavaScript to display an alert to notify that the execution was successful, merely for testing purposes. How can I do that in PHP object-oriented style?

I’ve tried:

public $msg='May the force be with you.';
$this->msg = new msg();

…but result was a white blank page. JavaScript piece I tried works well though. Below is the complete code:

<?php
class database {
    public $mysql;
        private $db_host='localhost';
        private $db_username='admin';
        private $db_password='password';
        private $db_name='db';

    function __construct() {
        $this->mysql = new mysqli($this->db_host, $this->db_username, $this->db_password, $this->db_name) or die (mysql_error() ); {
            echo 
            "<script type='text/javascript'>
            alert ('The Force will be with you, always.');
            </script>";
        }
    }
    function __destruct() {
        $this->mysql->close();
    }
}
?>

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories