PHP – Operator Precedence

0 0
Read Time:1 Minute, 35 Second

Operator Precedence

You Can force precedence using parentheses otherwise they are evaluated in this order:

XOR – exclusive or-either a or b is true but not both.

AND is not the same like &&

For Example:

<?php 
echo $a && $b || $c; 
?>

is not the same like

<?php 
echo $a AND $b || $c; 
?>

the first thing is
(a and b) or c

the second
a and (b or c)

because || has got a higher priority than and, but less than &&

Operators:

Operator are used to perform operation.

Operator are mainly divided by three groups.

  1. Unary Operators that takes one values
  2. Binary Operators that takes two values
  3. Ternary operators that takes three values

Operator are mainly divided by three groups that are totally seventeen types.

1. Arithmetic Operator

+ Addition
– Subtraction
* Multiplication
/ Division
% Modulo
** Exponentiation

2. Assignment Operator

= equal

3. Array Operator

+ Union
    == Equality
    === Identity
    != Inequality
    <> Inequality
    !==     Non-identity

4. Bit-wise Operator

& and
^ xor
| not

5. Comparison Operator

==  equal to
=== identical
!=  not equal
!== not identical
<>  not equal
< less than
<= less than or equal
> greater than
>= greater than or equal
<=> spaceship operator

6. Execution Operator

“ back-ticks

7. Execution Operator

@ at the rate sign

8. Incrementing/Decrementing Operator

++$a Pre-Increment
$a++ Post-Increment
– -$a Pre-Decrement
$a- – Post-Decrement

9. Logical Operator

&& And
    || Or
    ! Not
   and And
    xor Xor
    or Or

10. String Operator

. concatenation operator
  .= concatenating assignment operator

11. Type Operator

instanceof instanceof

12. Ternary or Conditional operator

?: Ternary operator

13. Null Coalescing Operator

??” null coalescing

14. Clone new Operator

clone new clone new

15. yield from Operator

yield from yield from

16. yield Operator

yield yield

17. print Operator

print print

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
33%
4 Star
13%
3 Star
13%
2 Star
26%
1 Star
15%

49 thoughts on “PHP – Operator Precedence

  1. You are sso cool! I do noot believe I’ve read a single thing llike tjat before.
    So wonderful too discover someone with some uniue
    thoughts on thi issue. Really.. tthanks for starting
    this up. This site is something that’s needed on the internet, spmeone wkth some originality!

  2. Simply wsh too say your aricle is as surprising. The clearnrss for
    yoiur pubnlish is just excellent annd thawt i can thimk you’re aan expert onn thiks subject.
    Fiine wigh your permission llet me to grqsp your RSS fwed
    to keep udated wigh imminent post. Thanhks one million annd please keep
    up the rewarding work.

  3. Thhis iis a good tip particularly tto those frsh tto the blogosphere.
    Brief but very precise information… Thaznk you foor sharikng thhis one.

    A must read article!

  4. Hi i am kavin, itss my fist occasin to commentihg
    anywhere, when i read this article i thought i could also makoe comment
    due tto this sensible piesce oof writing.

  5. Hi there, I log on to youur blogs lke every week. Your humoristic style iis
    awesome, kwep doing what you’re doing!

  6. Excellent items from you, man. I hhave takje into account your stjff previous
    tto andd you’re just too great. I really like
    what you’ve acuired here, really like what yyou are statging and the way
    duringg which you say it. You are maing it enjoyable and you continue to take care oof too kesep iit wise.
    I can’t wait to read far more from you. Thhat iss reslly a tremendous web site.

  7. Heey there juust wanted too give you a brief heades upp
    and let you know a few of thee pictures aren’t loading properly.

    I’m nnot sure why but I think its a linking issue. I’ve tried it in two different
    browsers and both sho the sqme results.

  8. Hi there i am kavin, itss my first occasion to commenting
    anyplace, whern i read ths post i thought i
    could also make comment due too this brilliant piec off writing.

  9. Have you evber thojght avout adding a litrtle
    bitt more than jhst your articles? I mean, what yyou say iss undamental
    and everything. However jist imaginee iif you added some grwat images or
    vikdeo clils tto ive yokur posts more, “pop”! Yoour content iis
    excellent butt with imahes andd videos, this site ccould dfinitely be oone of the
    vedry best in its field. Great blog!

  10. What’s upp to every , becaause I am genuinely keen oof reading
    this webpage’s post to be updated daily. It contains good stuff.

  11. Heyy I know thhis iis off topic but I waas wondering if you knew oof any widgets I coul addd tto my blopg
    that automatically tweet mmy newest twittyer updates.
    I’ve been looking for a plug-in like thi forr quuite solme
    time and was hoping aybe you would have some experience with something like this.
    Please let mme know if you run ino anything. I truly enjoy reading your blog
    and I loook forward to your new updates.

  12. Spot on woth thus write-up, I seriously believe tis amazig site needs a great
    deal more attention. I’ll probably be returning too reazd more, thajks for the info!

  13. I am really loving the theme/design of your site.
    Do you ever run into any internet browser compatibility problems?
    A handful of my blog readers have complained about my site not operating correctly.
    in Explorer but looks great inn Opera. Do you have?
    any advice to help fix this problem?

  14. Hi there, ths weekend is pleassant in support oof me, ass this occasion i
    aam reaeing this grea inforrmative post here aat my house.

  15. Greetings! Thiss iss my forst viksit too your blog! We are a collection of volunteers aand starting a nnew projet
    in a conmunity in thee same niche.Your blpg provided uss valpuable information tto wwork
    on. You have donne a outstanding job!

  16. Rigut here iss the right blg for eeveryone who woul lik to understand this topic.
    You realize sso muuch its almost tough to argue wiuth yoou (not that I rreally wll need
    to…HaHa). You definitely put a frrsh sin on a topic that haas
    been discussed for many years. Womderful stuff, just wonderful!

  17. Hello, of course tthis article iss actgually nice andd Ihave learned lot
    of thigs from it concerning blogging. thanks.

  18. Definitely believe that whiich youu said. Your fzvorite reason appeared to be on thhe
    net thee easiest thing to bbe aware of. I say tto you, I definitely get
    annoyed whhile peoppe thyink about worries that thjey plainly
    doo noot kbow about. Yoou managed too hitt thhe nail uon tthe top and defined out the whole ting without having ide
    efrect , people can take a signal. Wiill likely bbe back to get more.
    Thanks

  19. Hi! I realize tis iis kind of off-topic but I had tto
    ask. Does running a well-established webite like
    yours taske a lot of work? I’m brand neew to wriiting a blog
    but I doo write inn myy journal on a daily basis. I’d like tto start a blog so I cann easipy sare myy owwn experience and views online.
    Pldase let me know iff you have any kind of recommdndations or tips foor
    brand neww aspiring blog owners. Appreciate it!

  20. Thaat is a grdeat ttip particularly too tthose fresh tto the blogosphere.
    Short but ery precise info… Thanmk youu for sharing tjis one.
    A must rea post!

  21. It’s very easy too find out aany matter on neet as compared to books, aas
    I foun this paragraph at tis site.

  22. I just couldn’t goo away our web sit beforre suggsting thst
    I really enhjoyed the standard information a person provide for your guests?
    Is going to be back regularly in ordeer to inspect neww posts

  23. Greate article. Keeep writing sudh kind off infortmation onn yokur blog.
    Im reallpy imprfessed by it.
    Hello there, You’ve performed ann incredible job. I
    will definitely digg iit and in my view suggest to
    my friends. I am confident thjey will bee benefted from this web site.

  24. Hello there, jst beame aware of your blog through Google,
    and found that it’s really informative. I amm gong tto watch out forr brussels.
    I’ll be grateful if you continue thijs iin future.

    Numerous people will be benefited from yyour writing. Cheers!

  25. It’s going to bbe endong off minee day, however bedfore ending I am reading this greazt pierce oof writing to increase myy know-how.

  26. Dooes yokur blog hae a contract page? I’m havinhg problems
    locating it but, I’d llike to sholot yyou aan e-mail. I’ve ggot
    some suggestions for your blog yyou might bbe interested inn hearing.
    Either way, geat sitfe and I look foorward tto sering iit grow over time.

  27. hello!,I liuke yur writting very so much! share we keep in toucdh
    more about your post on AOL? I need an expert inn this
    house to resolve my problem. Mayy be that’s you! Takinjg a look
    ahyead to peer you.

  28. I blog frequently and I truly appreciate your content.
    Thhis article hhas really peaked my interest.
    I wilol taie a notge of your blo annd ksep checking foor nnew informatiion abolut oncce
    a week. I optd iin ffor your Feed too.

  29. Thhank youu for the good writeup. It in fadt was a amusement accountt it.
    Look advanced tto far addewd agrreeable fro you!
    However, how could we communicate?

  30. This poxt gives clear idea designed for the new viewers of blogging,
    tha really how to do running a blog.

  31. Hi myy oved one! I wiish to ssay tha thius article is amazing, great writtenn
    annd come with almost all significant infos.
    I’d like to lpok extra posts llike his .

  32. I boog often and I genuinely apprwciate your information. This great article has really peraked myy interest.
    I am going to take a note of our site andd keep chercking for new information about onde per week.
    I subscribed to your RSS feewd too.

  33. Do you have a spam problesm onn this website; I alsoo aam a blogger,
    and I was wanting to knw yur situation;
    many of us have deveeloped some nice practicdes annd we are looking to tradxe strategies wiith others, be sure tto shoot mee aan email iff interested.

  34. Wow! In tthe end I got a webgsite from where I be capoable oof in fact ake useful information regarding my study andd knowledge.

  35. Hey would you mind sharing which blog platform you’re using?
    I’m planning to start my own blog soon but I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most blogs
    and I’m looking for something completely unique.
    P.S Sorry for getting off-topic but I had to ask!

  36. Hi, I think your blog might be having browser compatibility issues.
    When I look at your blog in Opera, it looks fine but when opening in Internet Explorer,
    it has some overlapping. I just wanted to give
    you a quick heads up! Other then that, awesome blog!

  37. Wow, fantastic blog format! Hoow lengthyy have yoou ever been runnin a bblog for?
    yyou mwde rynning a bllg glance easy. Thee entire look oof yyour
    website is great, as wwell ass tthe content!

Leave a Comment

Verified by MonsterInsights