Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 05-03-2010
Member
 
Join Date: Apr 2009
Posts: 452
What are an Expressions in PHP?

Hello friends,
I have just started with the PHP programming language, and hence I don't know anything about it. I want to know about an expressions that are used in PHP. Before this I have used an expressions in C and C# programming language, but I want to use in PHP. So please explain me what are an Expressions in PHP? Hope that someone would help me soon.!!
Reply With Quote
  #2  
Old 05-03-2010
Member
 
Join Date: Mar 2008
Posts: 349
Re: What are an Expressions in PHP?

Expressions are the most important part of PHP. In PHP, almost everything you write is an expression. The easiest way to define an expression is "anything that has value." The simplest forms of expressions are constants and variables. When you write "$ a = 7", you assign the value '7 'to the variable $ a. Obviously, '7 'is 7 or, in other words '7' is an expression with the value 7. In this case, '7' is an integer constant. Hope that you would have understood the use of an expression.
Reply With Quote
  #3  
Old 05-03-2010
Member
 
Join Date: Jul 2006
Posts: 289
Re: What are an Expressions in PHP?

Slightly more complex examples for expressions are functions. For instance, consider the following function :
PHP Code:
<?php
function call ()
{
    return 
4;
}
?>
Assuming that you are familiar with the concept of functions, you'll agree that $ c = call() is equivalent to $ c = 4, and you are absolutely right. Functions are expressions with the value of their "return value". If call() returns 4, the value of the expression 'call()' is 4.
__________________
Signatures reduce available bandwidth
Reply With Quote
  #4  
Old 05-03-2010
Member
 
Join Date: Aug 2006
Posts: 227
Re: What are an Expressions in PHP?

Usually functions do not just return a static value but compute something. The values in PHP do not have to be integers, as is often the case. PHP supports four scalar variable types: integer values (whole), the floating point numbers (float), strings (string) and Boolean (boolean). For example a scalar variable is a variable that you can not break into pieces, unlike arrays. PHP also supports two composite types: arrays and objects. Each of these types of variables may be affected or returned by a function.
__________________
I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.
Reply With Quote
  #5  
Old 05-03-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: What are an Expressions in PHP?

The one good example of expression orientation is pre-increment and post-increment (and decrement). Users of PHP / FI 2 and those of many other languages are used to the notation of variable + + and variable -. These are increment and decrement. PHP / FI 2, the statement '$ a + +' has no value (that is to say that this is not an expression) and you can not use it. PHP adds the possibility to increment and decrement as is the case in the C language In PHP, like in C, there are two types of increment (pre-increment and post-increment). The two types of increment operator play the same role (that is, they increment the variable). The difference is the value of the increment operator. The operator pre-increment, which is written '$ variable + +' evaluates to the incremented value.
Reply With Quote
  #6  
Old 05-03-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: What are an Expressions in PHP?

One type of expression is very common expression comparison. These expressions evaluate to 0 or 1, ie TRUE or FALSE, respectively. PHP supports the comparison operators> (greater than) => (greater than or equal), == (equal), <(less than), <= (smaller or equal). These expressions are used routinely in conditional statements, such as if statements. The last thing worth mentioning is the truth value of expressions. When you test a variable in a conditional loop example, this does not interest you to know the exact value of the expression. But you only want to know if the result means TRUE or FALSE The constants TRUE and FALSE (case insensitive) are the two possible values for a boolean. When necessary, an expression is automatically converted to boolean.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What are an Expressions in PHP?"
Thread Thread Starter Forum Replies Last Post
Data type and expressions cloud101 Software Development 1 18-01-2012 11:47 PM
What are an expressions used in python? Atsushi Software Development 4 31-12-2010 12:46 AM
Question on regular expressions Logan 2 Software Development 5 12-02-2010 04:21 AM
What are the Operators and Expressions in C# ? kyosang Software Development 4 09-02-2010 06:32 AM
What are the Elements of Coldfusion Expressions Demetrius Software Development 3 30-03-2009 10:57 AM


All times are GMT +5.5. The time now is 03:22 AM.