Skip to main content

Reference - What does this symbol mean in PHP?


What is this?



This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.



Why is this?



Stack Overflow does not allow searching for particular characters. As a consequence, many questions about operators and other syntax tokens are not found easily when searching for them. This also makes closing duplicates more difficult. The list below is to help with this issue.



The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from the PHP Manual.



What should I do here?



If you have been pointed here by someone because you have asked such a question, please find the particular syntax below. The linked pages to the PHP manual along with the linked questions will likely answer your question then. If so, you are encouraged to upvote the answer. This list is not meant as a substitute to the help others provided.



The List



If your particular token is not listed below, you might find it in the List of Parser Tokens .





& Bitwise Operators or References






=& References






&= Bitwise Operators






&& Logical Operators






% Arithmetic Operators






!! Logical Operators






@ Error Control Operators






?: Ternary Operator






: Alternative syntax for control structures , Ternary Operator






:: Scope Resolution Operator , Namespaces






-> Classes And Objects






=> Arrays






^ Bitwise Operators






>> Bitwise Operators






<< Bitwise Operators






<<< Heredoc or Nowdoc






= Assignment Operators






== Comparison Operators






=== Comparison Operators






!== Comparison Operators






!= Comparison Operators






<> Comparison Operators






| Bitwise Operators






|| Logical Operators






~ Bitwise Operators






+ Arithmetic Operators , Array Operators






+= Assignment Operators






++ Incrementing/Decrementing Operators






.= Assignment Operators






. String Operators






, Function Arguments






$$ Variable Variables






` Execution Operator






<?= Short Open Tags






[] Arrays





Source: Tips4allCCNA FINAL EXAM

Comments

  1. Incrementing / Decrementing Operators

    ++ increment operator

    -- decrement operator

    Example Name Effect
    ---------------------------------------------------------------------
    ++$a Pre-increment Increments $a by one, then returns $a.
    $a++ Post-increment Returns $a, then increments $a by one.
    --$a Pre-decrement Decrements $a by one, then returns $a.
    $a-- Post-decrement Returns $a, then decrements $a by one.


    These can go before or after the variable. Putting this operator before the variable is slightly faster.

    If put before the variable, the increment / decrement operation is done to the variable first then the result is returned. If put after the variable, the variable is first returned, then the increment / decrement operation is done.

    For example:

    $apples = 10;
    for ($i = 0; $i < 10; ++$i)
    {
    echo 'I have ' . $apples-- . " apples. I just ate one.\n";
    }


    Live example

    In the case above ++$i is used, since it is faster. $i++ would have the same results.

    However, you must use $apples--, since first you want to display the current number of apples, and then you want to subtract one from it.

    You can also increment letters in PHP:

    $i = "a";
    while ($i < "c")
    {
    echo $i++;
    }


    Once z is reached aa is next, and so on.


    Note that character variables can be incremented but not decremented and even so only plain ASCII characters (a-z and A-Z) are supported.




    Stack Overflow Posts:


    Understanding Incrementing

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex