"www.111cn.net",""/> "www.111cn.net","">
search
Homephp教程PHP源码php ->和=>区别与实例教程

<script>ec(2);</script>

简单说一下就是
-> 调用对象的成员
=> 指定下标

下面来看几个实例关于-> 与=>代码,让你更清楚是什么用法与功能并且有什么区别了。
*/
// =>用法,可用到数组array,赋值与foreach赋值

$array = array("addr" => "www.111cn.net","tel" => "11111111");

print_r($array);

/*
结果为
Array
(
    [addr] => www.111cn.net
    [tel] => 11111111
)
*/

//用来foreach实例

foreach( $array as $v =>$_v )
{
 echo $_v,'
';
}

/*
结果
www.111cn.net
11111111

*/

// ->用法上面说了是用于对象的,那我们就来做个实验

class user{
 var $url ='www.111cn.net';
 
 public function showUrl()
 {
  echo $this->url;
 }
}

//调用 user类方法

$u = new user();
$u->showUrl();

/*
输出结果为 www.111cn.net

本文章原创于www.111cn.net[中国WEB第一站]转载注明来源

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.