首页 > 编程知识 正文

php中int函数的用法,index函数的用法示例

时间:2023-05-05 20:56:05 阅读:258499 作者:456

PHP Ds Stack类的Ds Stack::isEmpty()函数用于检查Stack是否为空。此方法返回一个布尔值,如果Stack为空,则返回True,否则返回False。

用法:

bool public DsStack::isEmpty ( void )

参数:此功能不接受任何参数。

返回值:如果堆栈为空,则此函数返回布尔值True,否则返回False。

以下示例程序旨在说明Ds Stack::isEmpty()函数:

程序1::

// PHP program to illustarte the

// isEmpty() function

// Create a Stack instance

$stack = new DsStack();

// Check if stack is Empty

var_dump($stack->isEmpty());

// Pushing elements to Stack

$stack->push("Welcome");

$stack->push("to");

$stack->push("GfG");

// Check if stack is Empty again

var_dump($stack->isEmpty());

?>

输出:

bool(true)

bool(false)

程序2::

// PHP program to illustarte the

// isEmpty() function

// Create a Stack instance

$stack = new DsStack();

// Check if stack is Empty

var_dump($stack->isEmpty());

// Pushing Mixed value elements to Stack

$stack->push("Welcome");

$stack->push("to");

$stack->push("GfG");

$stack->push(10);

$stack->push(5.5);

// Check if stack is Empty again

var_dump($stack->isEmpty());

?>

输出:

bool(true)

bool(false)

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。