php入門などの定義、構築関数
940 ワード
phpクラスの定義方法、および構造関数の使用、変数付与、変数取値.
<?php
class Animal{
private $name;
//
// _ _construct() ( , _)
function __construct($text){
$this->name = $text;
}
//
function set_name($text){
$this->name = $text;
}
//
function get_name(){
return $this->name;
}
}
$lion = new Animal("tomcat");
//$lion->set_name("Leo");
echo "Animal Name is ", $lion->get_name(), ".", "test"."122";
echo "<br />";
$color = "red";
echo "Roses are $color";
echo "<br />";
// 。 , :
echo 'Roses are $color';
?>
<!-- -->
<p>Roses are <?=$color?></p>
php , ,