+ 6
Yesâ
Following are some of the key aspects of a PHP class:
Define a class with keyword âclassâ followed by name of the class
Define the constructor method using â__constructâ followed by arguments. The object of the class can then be instantiated using ânew ClassName( arguments_list )â
Define class variables. One could access specifiers such as private, public, protected etc.
Define methods using âfunctionâ keyword. By default, PHP methods, if not specified with any access specifier becomes public in nature.
That is it!
+ 7
Of course. Here's my example of OOP and classes
https://code.sololearn.com/wZF3LsZ5DNia/?ref=app
+ 5
Show us a try.
Also check for same questions.
https://www.sololearn.com/Discuss/1316935/welcome-to-sololearn-forum/
All python concepts are explained in the tutorial here.
https://www.sololearn.com/Course/Python/
+ 4
Would you mind explaining why you ask so many unrelated questions(Python, PHP, Java) in a short period of time, all with a self-upvote?
https://www.sololearn.com/discuss/2151688/?ref=app
https://www.sololearn.com/discuss/2151649/?ref=app
https://www.sololearn.com/discuss/2151669/?ref=app
https://www.sololearn.com/discuss/2151656/?ref=app
https://www.sololearn.com/discuss/2151645/?ref=app
https://www.sololearn.com/discuss/2151679/?ref=app
If it is for that Asker badge in SoloLearn profile, may I remind you that these achievements are virtual and you can take them back to real life.
Only the programming knowledge developed can accompany you with your career. Please stay focus on learning.
+ 4
Why not do the PHP tutorial and find out.
+ 4
blackwinter I guess they are after php rather than python.
+ 4
blackwinter OK đđ
+ 3
Sonic doesn't matter .
+ 1
<?php
class Books {
/* Member variables */
var $price;
var $title;
/* Member functions */
function setPrice($par){
$this->price = $par;
}
function getPrice(){
echo $this->price ."<br/>";
}
function setTitle($par){
$this->title = $par;
}
function getTitle(){
echo $this->title ." <br/>";
}
}
?>
it is an example of creating class in php
Please note that php is a weekly typed programming language
+ 1
Yes you can
+ 1
claro que si amigo



