php-general Digest 4 Jan 2013 07:56:05 - Issue 8086
Topics (messages 320004 through 320030):
Re: Boolean type forced on string assignment inside if statement
320004 by: Geoff Shang
320005 by: John Iliffe
320006 by: Marc Guay
320007 by: John Iliffe
On 1/2/2013 2:02 PM, Marc Guay wrote:
Something else that's happening with this, which makes it a Bad Idea
(tm) is that when the operator is or, as it is in my real life
scenerio, the 2nd variable occasionally doesn't get populated if the
first one returns true.
if ($a = foo || $b = bar){
On Thu, 3 Jan 2013, Jim Giner wrote:
The only time I use a single '=' symbol in an if statement is when I forget
to use two of them! Must be my old school, old languages habits but this
style of programming reminds me of the days when we used to pack empty spaces
in assembler code with
On Thursday 03 January 2013 10:26:39 Jim Giner wrote:
On 1/2/2013 2:02 PM, Marc Guay wrote:
Something else that's happening with this, which makes it a Bad Idea
(tm) is that when the operator is or, as it is in my real life
scenerio, the 2nd variable occasionally doesn't get populated if
First, did the original poster realize that he was assigning a value to the
variable $a in the 'if' statement?
Hello,
Yes, I did, and if you read my responses you can see that I came to
the realisations you describe. I don't think that anyone suggested
there was a bug.
$a is true (ie it is
On Thursday 03 January 2013 11:33:22 Marc Guay wrote:
First, did the original poster realize that he was assigning a value
to the variable $a in the 'if' statement?
Hello,
Yes, I did, and if you read my responses you can see that I came to
the realisations you describe. I don't think
On Thu, Jan 3, 2013 at 11:49 AM, Marc Guay marc.g...@gmail.com wrote:
Hi John,
I just ran this:
if (($a = foo) || ($b = bar)){
echo $a.br /.$b;
}
and it only spat out foo so I'm guessing things have changed. :)
Marc
--
PHP General Mailing List (http://www.php.net/)
To
On Jan 3, 2013, at 11:49 AM, Marc Guay marc.g...@gmail.com wrote:
I just ran this:
if (($a = foo) || ($b = bar)){
echo $a.br /.$b;
}
and it only spat out foo so I'm guessing things have changed. :)
Marc
Marc et al:
I joined late into this conversation, so I may be missing the
Hi Tedd,
A little searching enlightened me to the fact that in other languages,
a single | or operator will cancel the short-circuiting so all of
the evaluations are done before proceeding. However, they don't seem
to exist in PHP so in your example it behaves the same as ||...?
On Jan 3, 2013, at 12:09 PM, David OBrien dgobr...@gmail.com wrote:
From what I understood about || is once it sees a true the whole statement
is regarded as true so nothing else following matters so PHP ignores
everything in the conditional after it evaluates as true...
and once it sees a
On 01/03/2013 09:25 AM, Marc Guay wrote:
Hi Tedd,
A little searching enlightened me to the fact that in other languages,
a single | or operator will cancel the short-circuiting so all of
the evaluations are done before proceeding. However, they don't seem
to exist in PHP so in your example it
I received the message below addressed only to me, but I believe the
group could benefit. It looks like the single pipe is a bitwise
operator so you will get an integer as a result (and probably other
weird things to discover when using it on non-numbers).
2013/1/3 Marc Guay marc.g...@gmail.com:
I received the message below addressed only to me, but I believe the
group could benefit. It looks like the single pipe is a bitwise
operator so you will get an integer as a result (and probably other
weird things to discover when using it on
Volmar Machado qi.vol...@gmail.com wrote:
When the one of the operators were 2, the cases with
returns 2 otherwise returns 0 (Or 1 when any operator is 1). And if
the operators are 1 and 2, return 0 too. Its curious for me.
is the bitwise and operator. You have to look at the binary
I am comparing to dates.
define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;
if ( date(m/d/Y, strtotime($jes)) date(m/d/Y, strtotime(WSOFFBEGIN)) )
{
$error = MUST begin after . WSOFFBEGIN . \n;
}
I cannot figure out why the $error is being assigned inside the if statement,
1/3/2012 is in fact less then 9/16/2012.
On Thu, Jan 3, 2013 at 3:57 PM, Marc Fromm marc.fr...@wwu.edu wrote:
I am comparing to dates.
define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;
if ( date(m/d/Y, strtotime($jes)) date(m/d/Y, strtotime(WSOFFBEGIN))
)
{
$error
Hi.
date returns a string
You should compare a different type for bigger/smaller than
HTH
Kind regards/met vriendelijke groet,
Serge Fonville
http://www.sergefonville.nl
Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
At 04:57 PM 1/3/2013, Marc Fromm wrote:
I am comparing to dates.
define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;
if ( date(m/d/Y, strtotime($jes)) date(m/d/Y, strtotime(WSOFFBEGIN)) )
{
$error = MUST begin after . WSOFFBEGIN . \n;
}
I cannot figure out why the $error
Thanks for the reply.
Every example on comparing dates in PHP that I found uses the strtotime
function which I am using. What other type can I use?
When is this example below supposed to work?
// your first date coming from a mysql database (date fields)
$dateA = '2008-03-01 13:34';
// your
Marc,
When you take a date and do a strtotime you are converting it to an int
which you can compare to each other much easier. So for your above example
you would be best doing.
define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;
if ( strtotime($jes) strtotime(WSOFFBEGIN) )
{
$error
Thanks Jonathan. I removed the date() syntax function and it works.
From: Jonathan Sundquist [mailto:jsundqu...@gmail.com]
Sent: Thursday, January 03, 2013 2:16 PM
To: Marc Fromm
Cc: Serge Fonville; php-general@lists.php.net
Subject: Re: [PHP] date problem
Marc,
When you take a date and do a
On 1/3/2013 5:22 PM, Marc Fromm wrote:
Thanks Jonathan. I removed the date() syntax function and it works.
From: Jonathan Sundquist [mailto:jsundqu...@gmail.com]
Sent: Thursday, January 03, 2013 2:16 PM
To: Marc Fromm
Cc: Serge Fonville; php-general@lists.php.net
Subject: Re: [PHP] date problem
Based on what I learned. I create this simple sample that can occurs
in a real world application.
This simulate a system that needs to send a mail when a flag ($mail)
is true, the system need to
check if the category is passed with the flag to know the type of mail to send.
Here is the results.
On 01/03/2013 01:57 PM, Marc Fromm wrote:
$jes = 01/03/2012;
# php -r echo 01/03/2012;
0.00016567263088138
You might want to put quotes around that value so it is actually a
string and does not get evaluated.
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP
On 01/03/2013 11:43 AM, Andreas Perstinger wrote:
is the bitwise and operator.
So is a single pipe.
http://php.net/manual/en/language.operators.bitwise.php
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe,
2013/1/4 tamouse mailing lists tamouse.li...@gmail.com
Bit operators and | are NOT and should NEVER be confused with
Logical operators and ||:
?php
/**
* Bit operators in PHP
*/
$format = Decimal: %2d Binary: %4b\n;
$a = 4;
$b = 6;
echo Variable \$a:\n;
printf($format, $a,
26 matches
Mail list logo