473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can a control statement go within a mail() function?

Hi,

I would like to put an IF statement within the mail() function. I've
tried this and searched around but haven't found anything written
about this. Is it possible? I've been doing somethings like :

mail ("Email", "Subject", "Body".if() {...}."", "From");

Sorry if this is a dumb question. BUT, if it works I will try similar
things in SELECT statements.

Thanks in advance
Jul 17 '05 #1
2 1556
Sigmund wrote:
Hi,

I would like to put an IF statement within the mail() function. I've
tried this and searched around but haven't found anything written
about this. Is it possible? I've been doing somethings like :

mail ("Email", "Subject", "Body".if() {...}."", "From");

Sorry if this is a dumb question. BUT, if it works I will try similar
things in SELECT statements.


Short Answer:

NO control structures in expressions. They're not the same things.

Better Answer:

This is a very common request, so PHP, among a few other languages, has
something called the ternary operator, which acts as an expression:

(expr1) ? (expr2) : (expr3)

expr1 is evaluated. If TRUE, expr2 is evaluated and is the result of the
ternary operator. Otherwise, expr3 is evaluated and becomes the value of
the ternary operator.

For example:

$is_it_a_dog = FALSE;

//
// animal has "cat" after this.
//
$animal = $is_it_a_dog ? "dog" : "cat";

$some_number = (time() % 2) == 0 ? pi() : 2.71828;

play around with it. it's likely what you want.
--
I am not an ANGRY man. Remove the rage from my email to reply.
Jul 17 '05 #2
On Tue, 07 Dec 2004 21:22:39 -0800, Mark <mw@ANGRYLanfear.com> wrote:
Sigmund wrote:
Hi,

I would like to put an IF statement within the mail() function. I've
tried this and searched around but haven't found anything written
about this. Is it possible? I've been doing somethings like :
Short Answer:

NO control structures in expressions. They're not the same things.

Better Answer:

This is a very common request, so PHP, among a few other languages, has
something called the ternary operator, which acts as an expression:


Thanks - I'm going to work on this.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dmiller23462 | last post by:
Hey guys.... I put an error-handling in my page and have it posted at the complete end of the code, see below(when people were putting in 's I was getting the delimiter errors). Great, I...
9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
13
by: Will Pittenger | last post by:
I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does...
8
by: Henk van Winkoop | last post by:
Hello, I debugged some html file and found this: ------------------------------------------------------------ <script language="JavaScript"> if ( some_statement ) { function MyFunction (...
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Buck Rogers | last post by:
Hi all! Newbie here. Below is an example from Teach Yourself C in 21 Days. My apologies if it is a bit long. What I don't understand is how the "get_data" function can call the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.