Jump to content

Para que server e quando se usa "->" este sinal em PHP?


Recommended Posts

Posted (edited)

Para que serve e quando se usa os simbolos -> em PHP?

$mail->Password = 'senha do email'; // PASSWORD DA CONTA DE E-MAIL !
$mail->Username = 'email'; //EMAIL
Edited by pwseo
tags code, syntax highlight.
Posted

PHP has two Object Operator namely -> and ::

-> is used when you are trying to call a method on an Instance and / or access an Instance property.

:: is used when you want to call a static method or call a parent class's version of a method within a child class.

Posted

No teu caso esse sinal serve para alterares os atributos Password e Username, que nada mais são que variáveis da classe.

Por exemplo:

A classe:

class Email {
public $Username = 'anonymous';
public $Password = NULL;
public function __construct(){
	#faz qualquer coisa.
}
}

Como chama-la e definir os atributos:

$email = new Email();
$email->Username = 'guest';
$email->Password = '123asd123';
  • Vote 1

developer @ filipealves.net

filipealvesbcl [a] gmail.com

github.com/filipealvesbcl

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.