コード例 #1
0
ファイル: teste2.php プロジェクト: adrianomelo5/magento
class Cat
{
    public $isAlive = true;
    public $numLegs = 4;
    public $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function meow()
    {
        return "Meow meow";
    }
}
$cat1 = new Cat("CodeCat");
echo $cat1->meow();
die;
?>

<!--<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />-->
<?php 
header("Content-type: text/html; charset=utf-8");
?>

<?php 
// Declarando os valores das variáveis
$a = 4;
$b = 2;
?>
<h2>Adição</h2>
<p>
コード例 #2
0
ファイル: closure.php プロジェクト: kravetz/php-tests
die;
print_r($GLOBALS);
die;
echo "<form action='closure.php' method='POST'>";
echo "<input type='text' name='a'>";
echo "<input type='text' name='b'>";
echo "<input type='text' name='c'>";
echo "<input type='text' name='d'>";
echo "<input type='text' name='e'>";
?>
  <input type='submit' name='action' value='Submit'>
  
  <?php 
echo "</form>";
echo file_get_contents("php://input");
die;
class Cat
{
    public $sound = "meow";
    function meow()
    {
        echo $this->sound . "<br>" . PHP_EOL;
    }
}
$showSound = function () {
    echo "Sound is " . $this->sound;
};
$lenny = new Cat();
//$showSound->bindTo($lenny);
$lenny->meow();
コード例 #3
0
<!DOCTYPE html>
<html>
    <head>
	  <title> Hora do Desafio! </title>
      <link type='text/css' rel='stylesheet' href='style.css'/>
	</head>
	<body>
      <p>
        <?php 
// Digite seu código aqui
class Cat
{
    public $isAlive = true;
    public $numLegs = 4;
    public $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function meow()
    {
        return 'Meow meow';
    }
}
$siames = new Cat('CodeCat');
echo $siames->meow();
?>
      </p>
    </body>
</html>
コード例 #4
0
ファイル: index.php プロジェクト: Talapius/forResume
<?php

include 'autoload.php';
$cat = new Cat('garfield');
echo $cat->getName() === 'garfield';
echo $cat->meow() === 'Cat garfield is saying meow';
コード例 #5
0
ファイル: cat.php プロジェクト: sgsani/meeting.local
 * User: HP
 * Date: 21.12.2015
 * Time: 23:09
 */
ini_set('display_errors', 1);
error_reporting(E_ALL);
class Animal
{
    public $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function getName()
    {
        echo $this->name;
    }
}
class Cat extends Animal
{
    function meow()
    {
        echo "Cat {$this->name} is saying meow";
        // getName() - это метод, а не свойство, поэтому нужны скобки
    }
}
$cat = new Cat('Garfield');
$cat->getName();
echo '<br>';
$cat->meow();
コード例 #6
0
<?php

class Cat
{
    public $isAlive = true;
    public $numLegs = 4;
    public $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function meow()
    {
        return "Meow meow";
    }
}
$cat = new Cat("CodeCat");
echo $cat->meow();