Skip to main content

Posts

Class and object

Creating a Class: To create a class use the class keyword and a name. Class names can be any combination of numbers and letters, although they must not begin with a number. The code associated with a class must be enclosed within braces. Class Defination: <?php class ClassName {   // class body } ?> For example: <?php class Books{ public $name; public $author; public function showBook(){ $name="Munna Madan"; echo $name; } } ?> Setting Properties and Methods In the class body are defined its properties and methods.         - Properties are variables defined inside the class.         - Methods are functions created within the class, with the word "function". The name of the variable (property) and the "function" word must be preceded by a specific attribute that determines the level of access that is allowed for the property or the method to be accessed outside its class. This can be: public, protec...

Object Oriented Programming

PHP is an object- oriented programming language. What is object-oriented programming (OOP)? Object-oriented programming(OOP) is a programming language using objects usually instances of a class, consisting of data fields and methods together with their interactions to design applications and computer programs. Main features of OOP are as below:  Class and object:     A class is a group of objects and an object is an instance of a class. It contains the code for properties and methods. Encapsulation:     Encapsulation is the ability of an object to protect the data (properties) of a class from outside influences. You can use a class (its properties) through an object instance, without having access to its code. Inheritance:     Inheritance is the ability of a class to copy or inherit the properties and methods of a parent class. Polymorphism:     Polymorphism is a class ability to do more different things, or use one clas...

Javascript popup window

Javascript popup window is the small window which is created by javascript. The syntax for javascript popup window is given below: window.open(url, name, [windowFeatures]) where url: The url of the page to open in the new window. name: A name is the name of the window. windowFeatures: They are the parameters which determines the various features of window to be included in the popup window like status bar, address bar,width,height, etc. The table shows the features and the string tokens you use: status     The status bar at the bottom of the window. toolbar     The standard browser toolbar, with buttons such as Back and Forward. location     The Location entry field where you enter the URL. menubar     The menu bar of the window directories     The standard browser directory buttons, such as What’s New and What’s Cool resizable     Allow/Disallow the user to resize the window....

Javascript: alert box, prompt box and confirm box

Alert box: It displays an alert dialog with a text message and OK button Example: Code: <html> <head> <script type=”text/javascript”> function showAlert() {     alert(“Hey!! This is an alert box”); } </script> </head> <body> <input type=”button” onClick=”showAlert()” value=”Show” /> </body> </html> In above example, only the text Hey!! This is an alert box appears. Prompt Box: Prompt is used to allow a user to enter something, and do something with that value. Code: <html> <head> <script type=”text/javascript”> function showPrompt() {     var name=prompt(“Please enter your name”, “Awaken Nepal”);     if(name!=null && name!=”")     {     document.write(“Hello”+name+”! How are you?”);     } } </script> </head> <body> <input type=”button” onClick=”showPrompt()...

To show/hide any content using javascript

Code: <script language=”javascript”> function showContent() { var ele = document.getElementById(“toggleText”); var text = document.getElementById(“displayText”); if(ele.style.display == “block”) { ele.style.display = “none”; text.innerHTML = “show”; } else { ele.style.display = “block”; text.innerHTML = “hide”; } } </script> <a id=”displayText” href=”javascript:showContent();”>show</a> <== click Here <div id=”toggleText” style=”display: none”><h1>This is hidden content</h1></div> Output: Before link is clicked After link is clicked  

HTML Layouts – Using Tables

Website Layouts Website Layout is very important to make your website look good. So you need to design your website properly. There is two ways of designing layout.  Using Table Using CSS(Without using table) Here, we will discuss using tables.