为了让自己熟悉 php,我正在做一个简单的项目;我来自 C# 背景。我遇到的一件事是类型意识的概念,因为没有......不是真的。例如:
<?php
include_once 'Player.php';
include_once 'DeckOfCards.php';
class Dealer extends Player {
public $deck;
public function __construct($name){
$this->name = $name;
$this->money = 10000;
}
public function setNewDeck(){
$this->deck = new DeckOfCards();
return true;
}
public function dealCard(){
return array_pop($deck);
}
public function shuffleDeck(){
shuffle($this->deck);
return true;
}
} ?>
问题是,当shuffleDeck()
调用该函数时,我收到警告:
shuffle() expects parameter 1 to be array, object given in MyFirstPhpProject\Object\Dealer.php on line 23
我在这里对这种方法缺少什么?