Is there any support for a negative condition in If statements in PHP.
Some tutorials ive found say that you can use the if!(condition)c md;
syntax. however i always get an error when i use that.
"Parse error: parse error, unexpected '!', expecting '(' in
TMP5rsqwh3ag.ph p on line 13"
I am runing PHP 4.3.2.
Regards
Tristan 4 108448
"Tristan" <tr************ @hotmail.com> wrote in message
news:3d******** *************** ***@posting.goo gle.com... Is there any support for a negative condition in If statements in PHP.
Some tutorials ive found say that you can use the if!(condition)c md; syntax. however i always get an error when i use that.
"Parse error: parse error, unexpected '!', expecting '(' in TMP5rsqwh3ag.ph p on line 13"
I am runing PHP 4.3.2.
Regards Tristan
<?php
$test="blah";
if(!$test=="tes t")print "test ain't test";
?>
remember, you need double = sign when testing this condition, or you'll end
up looking for a needle in a haystack. a single = first assigns the word
"test" to the variable and then tests the condition, resulting in a double
negative in this case.
Mich
Tristan wrote: Is there any support for a negative condition in If statements in PHP.
Unlike the subject, the correct syntax is (replace NOT with !)
if (NOT condition)
Examples
if (!$done) continue;
if (!preg_match('/hello/', $text)) echo "Please say hello.";
if (!((1 <= $qty) && ($qty <= 99))) echo "Please enter 1 to 99 only.";
Some tutorials ive found say that you can use the if!(condition)c md; syntax. however i always get an error when i use that.
That is wrong. Please inform the authors of those tutorials they have a
syntax error in their code. Should be
if (!condition) cmd;
--
USENET would be a better place if everybody read: | to email me: use | http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" | http://www.netmeister.org/news/learn2quote2.html | header, textonly | http://www.expita.com/nomime.html | no attachments. |
Danke for that. I went back to the original Tutorial and found it was
a Typo on their half which had thrown me.
"michel" <no@spam.please > wrote in message news:<cc******* ***@news.cistro n.nl>... "Tristan" <tr************ @hotmail.com> wrote in message news:3d******** *************** ***@posting.goo gle.com... Is there any support for a negative condition in If statements in PHP.
Some tutorials ive found say that you can use the if!(condition)c md; syntax. however i always get an error when i use that.
"Parse error: parse error, unexpected '!', expecting '(' in TMP5rsqwh3ag.ph p on line 13"
I am runing PHP 4.3.2.
Regards Tristan
<?php $test="blah"; if(!$test=="tes t")print "test ain't test"; ?>
remember, you need double = sign when testing this condition, or you'll end up looking for a needle in a haystack. a single = first assigns the word "test" to the variable and then tests the condition, resulting in a double negative in this case.
Mich
Tristan schrieb: "Parse error: parse error, unexpected '!', expecting '(' in TMP5rsqwh3ag.ph p on line 13"
simple: you wrote 'if !(...' instead of 'if (!... -- as you said, a typo., This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kendal Goodrich |
last post by:
In the setup project I am trying to create, I am wanting to search to see if
DirectX 8 is installed on the local machine. I figured the best way to
determine would be a registry key search, so I add one. The problem comes
in with the properties for the registry key search. The properties are
RegKey and Value. In viewing the registry editor, the registry key is
Software\Microsoft\DirectX. Within that, you have a value name and a value...
|
by: kelvSYC |
last post by:
This little bit of seeminly innocent code seems to give me these two
errors, all on the line that declares check(). Is there some part of
C++ that I'm missing out on?
class Condition {
public:
Condition() {}
virtual ~Condition() {}
virtual bool check() const;
|
by: Mark Anderson |
last post by:
A 'for' loop takes 3 arguments (initialize; test; increment). The 'test'
must equate as true or false
This doesn't work...
x = 5;
for (y=1; (y==5); y+=1) {
alert(x * y);
}
...nor does...
x = 5;
|
by: Dave Vandervies |
last post by:
Seen in a chunk of code I was looking at recently (not mine!):
--------
char* imgfilename;
sprintf((char*)imgfilename, "mask%d.dib", params.profile);
ReadImage((char*)imgfilename);
--------
(ReadImage is another part of the program's code that does exactly what
the reasonable reader would expect.)
For the CLC readers:
|
by: Ben R. |
last post by:
In an article I was reading
(http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/),
I read the following:
"The ending condition of a VB.NET for loop is evaluated only once, while the
C# for loop ending condition is evaluated on every iteration."
Is this accurate? I don't understand how you could get away without
evaluating the ending condition at every iteration. Otherwise, how would you
| |
by: joh12005 |
last post by:
Hello,
i posted for suggestions a little idea even if it still needs further
thoughts but as i'm sure you could help :)
if would like to implement some kind of Condition class which i coud
use to build bricks of more complex condition, conditions are based on
fields by using regexp
class Condition:
|
by: Ernesto |
last post by:
Within the scope of one Python file (say myFile.py), I'd like to print
a message on ANY exception that occurs in THAT file, dependent on a
condition.
Here's the pseudocode:
if anyExceptionOccurs():
if myCondition:
print "Here's my global exception message"
|
by: Matila |
last post by:
I am trying to create an update subsquery for the condition:
agent region region-ovrd-ind terminate-date
123 A Y 99999999 (active)
123 A Y 99999999 (active)
123 B N 20080101 (terminate)
123 B N 20080112 ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |