another topic though related to the previous post.
How do IF behave in php?
Say,
if( $goahead && copy($somefile1 , $somefile2) )
echo "hello world";
What if $goahead is false, will the if the fall, or test all of the
statements?
I can make a complex if system, but eventuallt I can keep it simple
here... 6 1607
On Mon, 07 Jan 2008 17:24:29 +0100, jodleren <so*****@hot.ee wrote:
if( $goahead && copy($somefile1 , $somefile2) )
echo "hello world";
What if $goahead is false, will the if the fall, or test all of the
statements?
In PHP, failure of $goahead will mean copy() is not checked/executed in
this case.
I can make a complex if system, but eventuallt I can keep it simple
here...
Well, short from a programmers standpoint indeed. Being more verbose often
doesn't hurt though, and makes code somewhat more flexible/debuggable.
Depends on the actual need offcourse.
--
Rik Wasmus
..oO(jodleren)
>How do IF behave in php?
Say, if( $goahead && copy($somefile1 , $somefile2) )
echo "hello world";
What if $goahead is false, will the if the fall, or test all of the statements?
PHP uses lazy evaluation. As soon as the result is known, the evaluation
stops. Because of this behaviour you can write things like
$rs = mysql_query(... ) or die(...);
Micha
"Michael Fesser" <ne*****@gmx.de wrote in message
news:pm******** *************** *********@4ax.c om...
.oO(jodleren)
>>How do IF behave in php?
Say, if( $goahead && copy($somefile1 , $somefile2) ) echo "hello world";
What if $goahead is false, will the if the fall, or test all of the statements?
PHP uses lazy evaluation. As soon as the result is known, the evaluation
stops. Because of this behaviour you can write things like
more pragmatic than lazy. if one condition is false, there is no possible
way other &&'ed conditions could change that result...so, why continue the
evaluation?
most languages do it this way. of those that i've used, vb was the only one
that continued to blindly evaluate conditions. it wasn't until vb.net that
the AndAlso and OrElse short-circuit constructs were added - 'short-circuit'
being even more descriptive than 'lazy' or 'pragmatic'.
cheers.
..oO(Steve)
>"Michael Fesser" <ne*****@gmx.de wrote in message news:pm******* *************** **********@4ax. com...
>PHP uses lazy evaluation. As soon as the result is known, the evaluation stops. Because of this behaviour you can write things like
more pragmatic than lazy. if one condition is false, there is no possible way other &&'ed conditions could change that result...so, why continue the evaluation?
Correct, and one common name for that technique is "lazy evaluation" (or
"delayed evaluation"): the result of an expression is only calculated if
and when it's really necessary.
>most languages do it this way. of those that i've used, vb was the only one that continued to blindly evaluate conditions. it wasn't until vb.net that the AndAlso and OrElse short-circuit constructs were added - 'short-circuit' being even more descriptive than 'lazy' or 'pragmatic'.
AFAIK "short-circuit" is more related to logical expressions, whereas
"lazy evaluation" is the more general name and applies to many other
things as well.
Micha
"Michael Fesser" <ne*****@gmx.de wrote in message
news:75******** *************** *********@4ax.c om...
.oO(Steve)
>>"Michael Fesser" <ne*****@gmx.de wrote in message news:pm****** *************** ***********@4ax .com...
>>PHP uses lazy evaluation. As soon as the result is known, the evaluation stops. Because of this behaviour you can write things like
more pragmatic than lazy. if one condition is false, there is no possible way other &&'ed conditions could change that result...so, why continue the evaluation?
Correct, and one common name for that technique is "lazy evaluation" (or
"delayed evaluation"): the result of an expression is only calculated if
and when it's really necessary.
>>most languages do it this way. of those that i've used, vb was the only one that continued to blindly evaluate conditions. it wasn't until vb.net that the AndAlso and OrElse short-circuit constructs were added - 'short-circuit' being even more descriptive than 'lazy' or 'pragmatic'.
AFAIK "short-circuit" is more related to logical expressions, whereas
"lazy evaluation" is the more general name and applies to many other
things as well.
hmmm...i didn't know that. first i'd heard of lazy eval.
On Jan 7, 6:54*pm, "Steve" <no....@example .comwrote:
"Michael Fesser" <neti...@gmx.de wrote in message
PHP uses lazy evaluation. As soon as the result is known, the evaluation
stops. Because of this behaviour you can write things like
most languages do it this way. of those that i've used, vb was the only one
that continued to blindly evaluate conditions. it wasn't until vb.net that
the AndAlso and OrElse short-circuit constructs were added - 'short-circuit'
being even more descriptive than 'lazy' or 'pragmatic'.
Well I would think the same way, but as you wrote, once tried VB one
knows, that one has to be careful...
There are really a lot of languages and scripts out there, so better
safe than not.
As for debugging/reading of code - this can really minimise code, and
by that give a better overview. Some may think it is a bit harder to
read, but I rather have a few lines of code than 3 screens of it.
Thanks, all This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tim Hastings |
last post by:
Hello,
I am using MyODBC from VB and I want to submit a batch of insert statements
in one call from my App. This is more efficient than making multiple calls
from code because of the communication overhead.
If I send a batch multiple statements separated by ; or ; + newline I get
syntax errors pointing at the start of the next statement..
If I fire each statement one at a time with the ; at the end there's no
problem.
|
by: DG |
last post by:
Hi,
Can anyone advise how to execute multiple statements in a single query
batch. For example-
update customers set customer_name = 'Smith' where customer_name =
'Smyth';
select * from customers;
I can execute each statement individually but get the 'you have an error in
|
by: Glenn Davy |
last post by:
Hidely hodley everyone
I'd like to run a series of of sql ddl statements against an msde2000
server. Normally I just deploy cmd file that impliments as osql statement,
but I'd like to store the 'patch' in an mdb file and use say ado or even
a passthrough statement to execute it.
The problem I've got Is I access (?) seems to require me to execute one
ddl at a time, otherwise the script breaks at the 'go' statement. While I
_could_ do...
|
by: Annie D via AccessMonster.com |
last post by:
Hi,
Is it possible to use multiple statements in SQL?? (I’ve never used it before)
:
I have one query that i'm working with, The statements I want to use are as
below, they all work individually, but not together, Access help is as much
use as a chocolate fireguard in this case! any suggestions or explainations
would be gratefully appreciated:
|
by: sureshjayaram |
last post by:
In some functions where i need to return multiple error codes at
multiple places, I use multiple return statements. Say for ex.
if (Found == 1)
{
if (val == -1)
return error1;
}
else
{
if (val2 == -1)
| |
by: G.Ashok |
last post by:
Hi,
Does anybody know how Multiple polymorphism can be done in VB.NET or DOT
doesn't support it? Is there any third party extensions available like for
Java to do this?
Regards,
....Ashok
------------------------------------------------------------------------
"It is beautiful for an engineer to shape and design the same way
|
by: =?Utf-8?B?QVRT?= |
last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g.
Please help,
I'm trying to write an ASP page to use ADO to run a long query against an
Oracle 10g database, to create tables, if they do not already exist. In terms
of ASP/ADO, that would be fine in a SQL Server Sense by a simply
ASP/Server-Side JavaScript as such:
var cnTemp = Server.CreateObject("ADODB.Connection");
|
by: =?Utf-8?B?VGVycnk=?= |
last post by:
I have coded multiple select statements in a single stored procedure, and
when I execute this procedure on SQL Server Management Express, I correctly
get multiple result sets. But, if I try to add a new Data Source to to my VB
2005 project, and point to this stored procedure, the data source wizard only
sees the 'first' select statement. Is there a way to load multiple tables in
a DataSet from a single stored procedure with multiple...
|
by: Tim |
last post by:
Hi Folks,
I'm used to a UNLOAD command that allows me to dump to a named flat
file the results of any SELECT statement. Hence one can build a single
SQL file which contains multiple SQL statements each of which
'unloads' to its own unique file.
unload to 'file1.txt' select * from ......
unload to 'file2.txt' select * from ......
and so on....
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |