Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.