Jump to content

[SOLVED] Need to clear some things up...


fsk141

Recommended Posts

Hello,

I'm new to php, and are having trouble with a few characters, and understanding what they are there for. I'm reading a book and upon reading I see these characters and would like to know what they are there for:

 

.=

=> (in arrays)

!$_POST (what is the ! mark for>)

 

If anyone could help me to understand what these are thanks in advance...

Link to comment
https://forums.phpfreaks.com/topic/62973-solved-need-to-clear-some-things-up/
Share on other sites

ill give example rather that explaining this

 

$x ='yes';

$x .='no';

now $x= yesno

but if

$x ='yes';

$x ='yes';

now $x= no

 

$x=array('a'=>1);

//=> its like saying index a is equal to 1

so it like $x['a'] = 1;

 

! means not

 

so when !$_POST  it means if not post or empty >:(

 

.= is a quick way of appending to a variable. So...

 

<?php

 $s = 'string';
 $s .= 'more';
 echo $s; // echos 'stringmore'

 // short for
 $s = 'this';
 $s = $s.'more';

?>

 

=> is used when creating associative arrays. Assciative arrays let you reference array values by a key instead of a numeric index. So...

 

<?php

 $a = array('foo' => 'bar');
 echo $a['foo']; // echos 'foo'

?>

 

The ! operator checks for false. So....

 

<?php

 $b = true;
 if (!$b) {
   echo '$b == false';
 } else {
   echo '$b == true';
 }

?>

 

Hope that helps. More details can be found here... the manual will be your life long friend.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.