Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

annas

New tutorial on PHP contents: 1.Logical operators. 2.while loop 3.foreach loop

  • one year ago
  • one year ago

  • This Question is Closed
  1. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    LOGICAL OPERATORS: Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value. However, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they may return a non-Boolean value. TYPES OF LOGICAL OPERATORS: $a and $b And TRUE if both $a and $b are TRUE. $a or $b Or TRUE if either $a or $b is TRUE. $a xor $b Xor TRUE if either $a or $b is TRUE, but not both. ! $a Not TRUE if $a is not TRUE. $a && $b And TRUE if both $a and $b are TRUE. $a || $b Or TRUE if either $a or $b is TRUE.

    • one year ago
  2. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    lets see examples: <?php // -------------------- // foo() will never get called as those operators are short-circuit $a = (false && foo()); $b = (true || foo()); $c = (false and foo()); $d = (true or foo()); // -------------------- // "||" has a greater precedence than "or" // The result of the expression (false || true) is assigned to $e // Acts like: ($e = (false || true)) $e = false || true; // The constant false is assigned to $f and then true is ignored // Acts like: (($f = false) or true) $f = false or true; var_dump($e, $f); // -------------------- // "&&" has a greater precedence than "and" // The result of the expression (true && false) is assigned to $g // Acts like: ($g = (true && false)) $g = true && false; // The constant true is assigned to $h and then false is ignored // Acts like: (($h = true) and false) $h = true and false; var_dump($g, $h); ?>

    • one year ago
  3. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    WHILE LOOP: while loops are the simplest type of loop in PHP. They behave just like their C counterparts. The basic form of a while statement is: while (expr) statement The meaning of a while statement is simple. It tells PHP to execute the nested statement(s) repeatedly, as long as the while expression evaluates to TRUE. The value of the expression is checked each time at the beginning of the loop, so even if this value changes during the execution of the nested statement(s), execution will not stop until the end of the iteration (each time PHP runs the statements in the loop is one iteration). Sometimes, if the while expression evaluates to FALSE from the very beginning, the nested statement(s) won't even be run once. Like with the if statement, you can group multiple statements within the same while loop by surrounding a group of statements with curly braces, or by using the alternate syntax: while (expr): statement ... endwhile;

    • one year ago
  4. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    Lets see an example: <?php /* example 1 */ $i = 1; while ($i <= 10) { echo $i++; /* the printed value would be $i before the increment (post-increment) */ } /* example 2 */ $i = 1; while ($i <= 10): echo $i; $i++; endwhile; ?> the working of while loop can be seen in the above example.

    • one year ago
  5. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    FOREACH LOOP: The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. There are two syntaxes: 1.foreach (array_expression as $value) statement 2.foreach (array_expression as $key => $value) statement The first form loops over the array given by array_expression. On each iteration, the value of the current element is assigned to $value and the internal array pointer is advanced by one (so on the next iteration, you'll be looking at the next element). The second form will additionally assign the current element's key to the $key variable on each iteration. Lets see an example:

    • one year ago
  6. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    Example 1: <?php $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; } // $arr is now array(2, 4, 6, 8) unset($value); // break the reference with the last element ?> Example 2: <?php foreach (array(1, 2, 3, 4) as &$value) { $value = $value * 2; } ?> NOTE: Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset().

    • one year ago
  7. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    So thats it for this tutorial. Do comment on the tutorial.

    • one year ago
  8. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    for those who join the tutorial now can also see the previous tutorials. 1. http://openstudy.com/study#/updates/4ffa87a8e4b058f8b7666f25 2. http://openstudy.com/study#/updates/4ffb14c9e4b058f8b766d273 3. http://openstudy.com/study?login#/updates/4ffd6086e4b00c7a70c5ed33

    • one year ago
  9. sami-21
    Best Response
    You've already chosen the best response.
    Medals 0

    good one !

    • one year ago
  10. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    @Muskan , @mathslover , @MathSofiya @mathhasproblems

    • one year ago
  11. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    thank you @sami-21

    • one year ago
  12. nilankshi
    Best Response
    You've already chosen the best response.
    Medals 0

    nice..

    • one year ago
  13. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    @lalaly , @ash2326 , @moha_10 , @malihe

    • one year ago
  14. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    @nilankshi thank you

    • one year ago
  15. Muskan
    Best Response
    You've already chosen the best response.
    Medals 0

    v nys....gr8 @annas

    • one year ago
  16. nilankshi
    Best Response
    You've already chosen the best response.
    Medals 0

    your welcome..@annas

    • one year ago
  17. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    @Muskan thanks

    • one year ago
  18. Hashir
    Best Response
    You've already chosen the best response.
    Medals 0

    great :D

    • one year ago
  19. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    @Hashir thank you

    • one year ago
  20. Muskan
    Best Response
    You've already chosen the best response.
    Medals 0

    ur wlc

    • one year ago
  21. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    @apoorvk , @Callisto

    • one year ago
  22. ParthKohli
    Best Response
    You've already chosen the best response.
    Medals 0

    Logical Operators https://developer.mozilla.org/en/JavaScript/Reference/Operators/Logical_Operators While loop: http://php.net/manual/en/control-structures.while.php Foreach loop: http://php.net/manual/en/control-structures.foreach.php Good luck doing it on your own next time.

    • one year ago
  23. mathslover
    Best Response
    You've already chosen the best response.
    Medals 0

    Wooh ! great tutorial annas. ... I think you are the master here of comp. science .. . thanks agan annas

    • one year ago
  24. ParthKohli
    Best Response
    You've already chosen the best response.
    Medals 0

    @mathslover Just look at the reply above yours.

    • one year ago
  25. mathslover
    Best Response
    You've already chosen the best response.
    Medals 0

    You mean that this is not personal tutorial ?

    • one year ago
  26. ParthKohli
    Best Response
    You've already chosen the best response.
    Medals 0

    No, it is not; and it hasn't cited the sources. Therefore, this can be called plagiarism. You have the evidence. "plagiarism (noun) The practice of taking someone else's work or ideas and passing them off as one's own." As defined by Dictionary.com

    • one year ago
  27. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    my dear friend parth pointing finger at someone is quite easy... but practically doing something is different i can create a whole new website using php. between i took help from open source php manuals it not so called plagiarism ... so next time try to be more help than that . thank you for your feed back

    • one year ago
  28. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    These are sentences taken to explain topics... i have a question the professor who taught us these subject they also take help from internet are they doing plagiarism too ??? i think not ... because things whose purpose is explain no matter what they are or where they are taken from comes under the category of helping .

    • one year ago
  29. mathslover
    Best Response
    You've already chosen the best response.
    Medals 0

    gr8 points @annas ..

    • one year ago
  30. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    thanks @mathslover

    • one year ago
  31. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    and one more thing i m just a source to bring stuff to help that has been developed many years ago

    • one year ago
  32. farmdawgnation
    Best Response
    You've already chosen the best response.
    Medals 0

    @annas I'm afraid Parth has a point. Although you wrote your examples on your own, you did take content from MDN and the PHP manual verbatim without citation, and that's plagiarism. I'm going to let Colm decide how he wants to handle this (either by deleting the question, etc, etc) - but you definitely should not do that again without providing links to the sources in YOUR posts.

    • one year ago
  33. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    ok @farmdawgnation

    • one year ago
  34. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    @cshalvey just want to say one thing php manuals are open source so if i took help to explain some concepts then whats wrong with it alot of people here do such stuff why i m being pointed ?

    • one year ago
  35. cshalvey
    Best Response
    You've already chosen the best response.
    Medals 1

    @Annas - Others *have* been warned about this kind of behavior. The issue here is not that you used the material - as you said, it's open-source so that's fine. The issue is *crediting* the source of this material. Otherwise, it does qualify as plagiarism as it appears you are passing off other people's work as your own. Please remember this in the future, as plagiarism is a very important issue to be aware of - ESPECIALLY now when every source of information is easily available on the internet. Thank you.

    • one year ago
  36. moha_10
    Best Response
    You've already chosen the best response.
    Medals 0

    wow awesome annas good job

    • one year ago
  37. annas
    Best Response
    You've already chosen the best response.
    Medals 13

    Ok @cshalvey i'll be careful next time.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.