codescracker


php

PHP Object Oriented Programming



« Previous Tutorial Next Tutorial »


PHP is an object oriented scripting language. Here are the terms related to object oriented programming:

You will learn all about the above listed object oriented concept available in PHP programming step by step devided into separate tutorials. For now let's take example on object oriented programming in PHP.

PHP Object Oriented Programming Example

Here is an example on object oriented concept in PHP.

<!DOCTYPE html>
<html>
<head>
	<title>Object Oriented Programming in PHP</title>
</head>
<h3>Object Oriented Programming Example in PHP</h3>
<body>
<?php
	// This example is based on object oriented concept
	// available in PHP - CodesCracker
	class oop_class
	{
		public $oop_member_var = "oop_member_var member variable";
		public $oop_function_name = "oop_member_function";
	}
	function oop_member_fun()
	{
		echo "Inside oop_member_fun()";
	}
	$oop_class = new oop_class;
	
	// to access member variables in an object,
	// you can use another variable as name 
	// as shown here
	$element = "oop_member_var";
	echo $oop_class->$element;
?>
</body>
</html>

Here is the sample output produced by the above object oriented example code in PHP.

php object oriented

« Previous Tutorial Next Tutorial »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test