Hi,
I have some basic php knowledge. I want to know about ' -> ' sign. What does this arrow means? I know it is very sipmle question but don't know. I am learning php from my own effort.

Jahur

Recommended Answers

All 3 Replies

An example is an array, where you define keys:

$myArray = array("name" => "John", "street" => "long street");

Just saw that you asked about -> and not => :-)

-> is used when you are dealing with classes and objects:

class foo
{
    function do_foo()
    {
        echo "Doing foo."; 
    }
}

$bar = new foo;
$bar->do_foo();

Take a look at this side, and use the code in your own script, as a practise, and see what is being output to the screen, would be the best practice, to just jump into it :-)

Reference: http://php.net/manual/en/language.types.object.php

Klemme

commented: Thank you so much much klemme. You really understand me. Really thanks +0

what i understand by the ' -> ' symbol you are trying to figure out, must be how you call a method of a function using its object.

$dbname="xyz";
$ob=new common_function();
$connect=$ob->db_connect($dbname);

Thanks Klemme. You give me a detailed concept.Also thanks for the referrence link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.