<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Class &#8211; Best DevOps</title>
	<atom:link href="https://www.bestdevops.com/tag/class/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bestdevops.com</link>
	<description>Lets Learn, Do it &#38; Share! Thats a Best DevOps!!!</description>
	<lastBuildDate>Wed, 25 May 2022 08:50:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>Object-Oriented Programming In Php</title>
		<link>https://www.bestdevops.com/object-oriented-programming-in-php/</link>
					<comments>https://www.bestdevops.com/object-oriented-programming-in-php/#respond</comments>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Fri, 06 May 2022 08:31:00 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Object]]></category>
		<category><![CDATA[Object-Oriented Programming in php]]></category>
		<category><![CDATA[Oops concept in php programing]]></category>
		<category><![CDATA[Some rules are here of class:]]></category>
		<category><![CDATA[Tutorial of Object-Oriented Programming in Php Programming]]></category>
		<guid isPermaLink="false">https://www.bestdevops.com/?p=23416</guid>

					<description><![CDATA[Object-oriented programming is a technique that solves problems by breaking them down into objects. Object-oriented programming aims to implement real-world [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Object-oriented programming is a technique that solves problems by breaking them down into objects. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc.</p>



<p class="wp-block-paragraph">Object-oriented programming is about creating objects that contain both data and methods, whereas Procedural programming is about writing procedures or methods that operate on data.</p>



<p class="wp-block-paragraph"><strong>Classes and objects are the two main aspects of object-oriented programming:</strong></p>



<ul class="wp-block-list"><li>Class</li><li>Object</li></ul>



<p class="wp-block-paragraph">First let’s start with the example of OOp after that we know more about it</p>



<p class="wp-block-paragraph"><strong>Example :</strong></p>



<p class="wp-block-paragraph">Class = Fruit.<br>Object = Mango, orange ,Apple, Banana.<br>Other example :<br>Class = A specific car model, such as Audi A4, BMW I8, Maruti Suzuki etc.<br>Object = A specific car of any model like the car you own</p>



<p class="wp-block-paragraph">Let’s learn a lot about classes and objects</p>



<h2 class="wp-block-heading">Class</h2>



<p class="wp-block-paragraph">Php class is group of value with set of operations to manipulate this values. Classes facilitate modularity and information hiding .classes are used to defined a new data type.</p>



<h2 class="wp-block-heading">Some rules are here of class:</h2>



<ul class="wp-block-list"><li>The class name can be any valid label.</li><li>It can not be reserved word</li><li>A valid class name starts with a letter or underscores, followed by any number of letter ,number or underscore.</li></ul>



<p class="wp-block-paragraph"><strong>Syntax:</strong></p>



<pre class="wp-block-preformatted">class Classname
{
var $variable_name;
var $variable _name;
function Method_name()
{
body of Mathod
}
function Method_name(parameter_list)
{
Body of Method
}
}</pre>



<p class="wp-block-paragraph"><strong>Example of class:</strong></p>



<pre class="wp-block-preformatted">class Model
{
var $model;
function showModel ($number)
{
$this-&gt; model=$nunber;
echo "Number:$this-&gt;model";
}
}</pre>



<h2 class="wp-block-heading">Object</h2>



<p class="wp-block-paragraph">Object is class type variable. Each time you create an object of class a copy of each variables defined in the class is the class is created. In other words you can say that each object of a class has its own copy of data members of defined in the class. Member function have only one copy shared by the all the objects of that class. All the objects may have their own value of variables.</p>



<p class="wp-block-paragraph">The new Operator is used to create an object.</p>



<p class="wp-block-paragraph"><strong>Syntax</strong>:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">$object_name =<span class="hljs-keyword">new</span> class_name ;</code></span></pre>


<h3 class="wp-block-heading">How to Access class member using object</h3>


<pre class="wp-block-code"><span><code class="hljs language-xml"><span class="hljs-tag">&lt;<span class="hljs-name">mark</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"has-inline-color has-primary-color"</span>&gt;</span>-&gt;<span class="hljs-tag">&lt;/<span class="hljs-name">mark</span>&gt;</span>operator is used to access class menber using object .

Object _name-&gt;variable_name;
$samsung-&gt;model;

Object_name-&gt;method() 
$car-&gt;Model();
 
Object_name-&gt;method_name(parameter_list)
$car-&gt;Model('BMW');</code></span></pre>


<h3 class="wp-block-heading">let’s have an example of Class and object</h3>



<pre class="wp-block-preformatted">    &lt;?php
    class calculation   //--------------Class
    {
        public $a,$b,$c;   //----------properties
        function sum()      //--------------method
        {
            $this-&gt;c = $this-&gt;a+$this-&gt;b;
            return $this-&gt;c;
        }
        function sub()
        {
            $this-&gt;c= $this-&gt;a-$this-&gt;b;
            return $this-&gt;c;
         }
    }
    $c1=new calculation();//-------------object

    $c1-&gt;a=20;
    $c1-&gt;b=10;

    $c2=new calculation();

    $c2-&gt;a=20;
    $c2-&gt;b=10;

    echo"sum value of c1 :". $c1-&gt;sum() ."&lt;br/&gt;"; 
    echo"subtraction value of c2 :" .$c2-&gt;sub();
    ?&gt;</pre>



<h2 class="wp-block-heading">why use Object-Oriented Programming</h2>



<ul class="wp-block-list"><li>Code more Modular and Reusable</li><li>Well Orginised code</li><li>Easier to debug</li><li>Best for medium to large website projects</li></ul>



<h2 class="wp-block-heading">Tutorial of Object-Oriented Programming in Php Programming</h2>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="PHP Fundamental Tutorials with Basic Demo by Chentan in 2020 - Part-1" width="900" height="506" src="https://www.youtube.com/embed/pBmXmnWqdoA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/object-oriented-programming-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
