<?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>what is class &#8211; Best DevOps</title>
	<atom:link href="https://www.bestdevops.com/tag/what-is-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, 13 Apr 2022 10:22:45 +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</title>
		<link>https://www.bestdevops.com/object-oriented-programming/</link>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Wed, 13 Apr 2022 10:22:43 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Oops concept in php programing]]></category>
		<category><![CDATA[what is class]]></category>
		<category><![CDATA[what is object]]></category>
		<guid isPermaLink="false">https://www.bestdevops.com/?p=23351</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.<br>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&#8217;s start with the example of OOp after that we know more about it</p>



<p class="wp-block-paragraph"><strong>Example :<br></strong>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&#8217;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>



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



<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-code"><span><code class="hljs language-php"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Classname</span>
</span>{
<span class="hljs-keyword">var</span> $variable_name;
<span class="hljs-keyword">var</span> $variable _name;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Method_name</span><span class="hljs-params">()</span>
</span>{
body of Mathod
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Method_name</span><span class="hljs-params">(parameter_list)</span>
</span>{
Body of Method
}
}</code></span></pre>


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


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Model</span>
</span>{
<span class="hljs-keyword">var</span> $model;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">showModel</span> <span class="hljs-params">($number)</span>
</span>{
<span class="hljs-keyword">$this</span>-&gt; model=$nunber;
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Number:$this-&gt;model"</span>;
}
}</code></span></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 .<br>In other words you can say that each object of a class has its own copy of data members of defined in the class.<br>Member function have only one copy shared by the all the objects of that class.  All the Object may have their own value of variables.<br>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>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow"><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">style</span>=<span class="hljs-string">"background-color:rgba(0, 0, 0, 0)"</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></div></div>



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


<pre class="wp-block-code"><span><code class="hljs language-xml">    <span class="php"><span class="hljs-meta">&lt;?php</span>
    <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">calculation</span>   //--------------<span class="hljs-title">Class</span>
    </span>{
        <span class="hljs-keyword">public</span> $a,$b,$c;   <span class="hljs-comment">//----------properties</span>
        <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sum</span><span class="hljs-params">()</span>      //--------------<span class="hljs-title">method</span>
        </span>{
            <span class="hljs-keyword">$this</span>-&gt;c = <span class="hljs-keyword">$this</span>-&gt;a+<span class="hljs-keyword">$this</span>-&gt;b;
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>-&gt;c;
        }
        <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sub</span><span class="hljs-params">()</span>
        </span>{
            <span class="hljs-keyword">$this</span>-&gt;c= <span class="hljs-keyword">$this</span>-&gt;a-<span class="hljs-keyword">$this</span>-&gt;b;
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">$this</span>-&gt;c;
         }
    }
    $c1=<span class="hljs-keyword">new</span> calculation();<span class="hljs-comment">//-------------object</span>

    $c1-&gt;a=<span class="hljs-number">20</span>;
    $c1-&gt;b=<span class="hljs-number">10</span>;

    $c2=<span class="hljs-keyword">new</span> calculation();

    $c2-&gt;a=<span class="hljs-number">20</span>;
    $c2-&gt;b=<span class="hljs-number">10</span>;

    <span class="hljs-keyword">echo</span><span class="hljs-string">"sum value of c1 :"</span>. $c1-&gt;sum() .<span class="hljs-string">"&lt;br/&gt;"</span>; 
    <span class="hljs-keyword">echo</span><span class="hljs-string">"subtraction value of c2 :"</span> .$c2-&gt;sub();
    <span class="hljs-meta">?&gt;</span></span>
</code></span></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>
					
		
		
			</item>
	</channel>
</rss>
