Jump to content

Recommended Posts

I'm going through this book and I've came across this operator

 

'|'  What purpose does it serve?

 

This is the example I was given

 

echo '|'.$products[0][0].'|'.$products[0][1].'|'.$products[0][2].'|<br />';

 

It's printing the products array by key and value, but I don't know what that operator is.

 

 

Link to comment
https://forums.phpfreaks.com/topic/186074-question-about-syntax/
Share on other sites

'|'  What purpose does it serve?

 

In this circumstance it doesn't signify anything more than to be a separator for each array value.

 

Generally the pipe '|' symbol is used for the logical operator 'OR'.  Read more here:

http://php.net/manual/en/language.operators.logical.php

The single pipe is used for bitwise operations (working on binary), the double pipe is used as Maq said for logical operations; the '|' in your example, as Maq also said, isn't any special syntax, it's just that character in a string.

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.