本文整理汇总了PHP中Student::setGPA方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::setGPA方法的具体用法?PHP Student::setGPA怎么用?PHP Student::setGPA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Student
的用法示例。
在下文中一共展示了Student::setGPA方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printName
}
public function printName()
{
echo "name: " . $this->name . PHP_EOL;
}
public function setGPA($gpa)
{
$this->gpa = $gpa;
}
public function printMajor()
{
echo "Major: " . $this->major . PHP_EOL;
}
}
$myStudent = new Student("Steve");
$myStudent->setGPA(2.3);
$myStudent->printName();
$myStudent->major = "Information Tech";
$var = "some value";
$number = 41234213424.0;
$realnumber = 12341234.1241241;
//this is also a comment, datebayo!
$arr = array();
$arr[] = 5;
$arr[] = "words";
$arr[] = 5345.5345;
$arr[] = array("food", "water", "shelter");
print_r($arr);
/*
this
示例2: PrintStudent
}
public function PrintStudent()
{
echo "Student: " . PHP_EOL;
echo " name: " . PHP_EOL;
echo " address: " . PHP_EOL;
echo " gpa: " . PHP_EOL;
echo " year: " . PHP_EOL;
}
public function setGpa($gpa)
{
$this->gpa = $gpa;
}
}
$myStudent = new Student("Steve");
$myStudent->setGPA("2.3");
$myStudent->major = "Information Technology";
$myStudent->printName();
/*
this
whale
block
of comments
*/
$var = "some value";
$var = $var . " some other value";
$number = 412342134;
//thi is is a comment
$realNumber = 12341234.1241241;
//this is also a comment, datebayo
$arr = array();
示例3: __construct
echo "begin script " . $argv[0] . PHP_EOL;
class Student
{
private $name;
private $address;
private $gpa;
private $year;
public function __construct($name)
{
$this->name = $name;
# "this" changes private or public variables with whatever variable you give it
}
public function printName()
{
echo "name: " . $this->name . PHP_EOL;
}
public function setGPA($gpa)
{
$this->gpa = $gpa;
echo "gpa: " . $gpa . PHP_EOL;
}
}
$myStudent = new Student("Steve");
$myStudent->printName();
$myStudent->setGPA(4.0);
$var = "some value";
$number = 248573289;
$realNumber = 1234.453;
$arr = array();
//print_r($arr);
echo "end script " . $argv[0] . PHP_EOL;
示例4: printName
}
public function printName()
{
echo "name: " . $this->name . PHP_EOL;
}
public function setGPA($gpa)
{
$this->gpa = $gpa;
}
public function printGPA()
{
echo "GPA: " . $this->gpa . PHP_EOL;
}
}
$myStudent = new Student("Joshua");
$myStudent->setGPA(3.43);
$myStudent->printName();
$myStudent->printGPA();
$myStudent->major = "Computing and Business";
$var = "some value";
$number = 2223243;
$realNumber = 1233223.233323;
$arr = array();
$arr[] = 5;
$arr[] = "words";
$arr[] = 3453434.3443;
$arr[] = array("food", "water", "shelter", "heart");
//print_r($arr);
//gives information about type of variable
//var_dump($arr);
echo "end script " . $argv[0] . PHP_EOL;