Re: [PHP] How do YOU set default function/method params?

2009-10-06 Thread Jim Lucas

paragasu wrote:

why bother, i use available good library

http://swiftmailer.org/



Ok, bad example. I already use SwiftMailer.  My "problem" though has nothing to do with sending an 
email.  I should have known someone would take it too literally.


Think a little more general.  This is not a specific thing to simply sending an 
email.

Could be database method calls from a class object, HTML CGI function, etc...

As for a different example.  Say you had a function that you had to pass (multiple) arguments to. 
But, with those arguments, you had defaults that you would like to inside the function even if they 
were not sent when you called your function.  But you do not want to be forced into entering ALL the 
arguments of a function call in a certain order.


Try this

function createHTMLBox($title, $content, $params=array() ) {

$defaults = array(
'id' = uniq(),
'class'  = 'box',
'encode' = TRUE,
);

$params += $defaults;

if ( $params['encode'] ) {
$title   = htmlspecialchars($title);
$content = htmlspecialchars($content);
}

# Obviously, I will be using the DomDocument class for this in the real 
world
# But for simplicities sake, I used the following.
$box = <<
  {$title}
  {$content}


BOX;

return $box;

}


Then, I call it like this:

echo createHTMLBox('This is my TITLE',
   'Item 1Item 2',
   array('encode' => FALSE));

echo createHTMLBox('This is my TITLE',
   'Item 1Item 2');

Both of the above will have different output to the screen.

Hope this clears things up.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Spry, XML, PHP and XSLT Hell

2009-10-06 Thread Tommy Pham
- Original Message 
> From: Andrew Mason 
> To: Nathan Nobbe 
> Cc: Matthew Croud ; PHP General list 
> 
> Sent: Mon, October 5, 2009 8:56:12 PM
> Subject: Re: [PHP] Spry, XML, PHP and XSLT Hell
> 
> On Tue, Oct 6, 2009 at 4:37 AM, Nathan Nobbe wrote:
> > On Mon, Oct 5, 2009 at 10:10 AM, Matthew Croud wrote:
> >
> >> Hello,
> >>
> >> Is there anyone here who uses Spry with XML and PHP and understands XSLT,
> >> At the moment i'm in development hell and have a rather bloated question to
> >> ask someone who is knowledgeable in the above areas.
> >>
> >> My head is about to explode and I can't find any answers,
> >> If there are Spry/XML folk here i'll spill the beans about my issue.
> >>
> >
> > ive not used spry, but have the rest of the lot.., hell, i think we can give
> > it a crack..; lay it on us brother ;)
> >
> > -nathan
> >
> 
> I don't know what spry is but I use PHP and XSLT all the time.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Spry is Adobe's AJAX framework similar to jQuery.  Are you having problems 
doing remote ajax call for xml data via Spry?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Time Problem: always ten past xx

2009-10-06 Thread Matthias Laug

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date  
and time.


So I get for example "10:30" and "06.10.2009". Standard german time  
format. Now I try to get the correct timestamp:


$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Jason
Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime 

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com] 
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date  
and time.

So I get for example "10:30" and "06.10.2009". Standard german time  
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Mert Oztekin
You also write the answer

var_dump(strftime("%d.%m.%Y %H:%m",$time));

there are 2 %m  you see? %m is month :)

for minute use %i


-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: Tuesday, October 06, 2009 10:53 AM
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve 
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve 
mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak 
?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz 
mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, 
b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar 
sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


Re: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Matthias Laug

argh, why do I always stick to the stupid questions :( sorry

Am 06.10.2009 um 10:03 schrieb Mert Oztekin:


You also write the answer

var_dump(strftime("%d.%m.%Y %H:%m",$time));

there are 2 %m  you see? %m is month :)

for minute use %i


-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: Tuesday, October 06, 2009 10:53 AM
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  
Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere  
özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen  
gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz.  
Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi  
bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve  
bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından,  
bütünlüğünün ve gizliliğinin korunamamasından, virüs  
içermesinden ve bilgisayar sisteminize verebileceği herhangi bir  
zarardan sorumlu tutulamaz.


This message and attachments are confidential and intended for the  
individual(s) stated in this message. If you received this message  
in error, please immediately notify the sender and delete it from  
your system. Our company has no legal responsibility for the  
contents of the message and its attachments. Our company shall have  
no liability for any changes or late receiving, loss of integrity  
and confidentiality, viruses and any damages caused in anyway to  
your computer system.


Matthias Laug
Schillerstraße 36
10627 Berlin

Tel.: 0176 / 20 14 21 63
eMail: matthias.l...@gmail.com





RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Mert Oztekin
Jason,

%M is also month:

Month --- ---
F A full textual representation of a month, such as January or March January 
through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31

Time --- ---
i Minutes with leading zeros 00 to 59

http://tr.php.net/manual/en/function.date.php



-Original Message-
From: Jason [mailto:networkad...@emarket2.com]
Sent: Tuesday, October 06, 2009 11:04 AM
To: 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve 
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve 
mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak 
?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz 
mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, 
b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar 
sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


[PHP] Re: Time Problem: always ten past xx

2009-10-06 Thread Carsten Wiedmann
Matthias Laug schrieb:
> var_dump(strftime("%d.%m.%Y %H:%m",$time));
   ---^
> The minutes are always "10", no matter what time I get.

"%m" = month
"%M" = minute

Regards,
Carsten


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Mert Oztekin
My mistake,

I thought it was date() now strftime()
Sorry

(why do php developers create two different standarts for such similiar 
functions???☺ )

_
From: Mert Oztekin
Sent: Tuesday, October 06, 2009 11:07 AM
To: 'Jason'; 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx


Jason,

%M is also month:

Month --- ---
F A full textual representation of a month, such as January or March January 
through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31

Time --- ---
i Minutes with leading zeros 00 to 59

http://tr.php.net/manual/en/function.date.php



-Original Message-
From: Jason [mailto:networkad...@emarket2.com]
Sent: Tuesday, October 06, 2009 11:04 AM
To: 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  
Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve 
gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve 
mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz 
mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, 
bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar 
sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


RE: [PHP] A really wacky design decision

2009-10-06 Thread Andrea Giammarchi


> but is implicitly converted into strings when it is entered.

use floatVal($str1) === floatVal($str2) then ... I honestly cannot spot any 
problem in what you wanna do, I can just spot an error in the root of the 
process: threat strings as numbers, comparing potatoes and tomatoes ... 

there are filters used for validation as well in php, maybe those filters, 
hopefully faster than PCRE, could help you to understand if a string is a 
number, or not.

Regards
  
_
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010

RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Jason
Hi Mert,

But we're not talking about date() here, we're talking strftime().

According to the manual %i doesn't do anything in strftime(). Closest match
is %I which is 12-hour format for hours.

HTH
J

-Original Message-
From: Mert Oztekin [mailto:mozte...@anadolusigorta.com.tr] 
Sent: 06 October 2009 09:07
To: 'Jason'; 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Jason,

%M is also month:

Month --- ---
F A full textual representation of a month, such as January or March January
through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31

Time --- ---
i Minutes with leading zeros 00 to 59

http://tr.php.net/manual/en/function.date.php



-Original Message-
From: Jason [mailto:networkad...@emarket2.com]
Sent: Tuesday, October 06, 2009 11:04 AM
To: 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz
ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili
olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r.
?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge?
ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s
i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan
sorumlu tutulamaz.

This message and attachments are confidential and intended for the
individual(s) stated in this message. If you received this message in error,
please immediately notify the sender and delete it from your system. Our
company has no legal responsibility for the contents of the message and its
attachments. Our company shall have no liability for any changes or late
receiving, loss of integrity and confidentiality, viruses and any damages
caused in anyway to your computer system.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Spry, XML, PHP and XSLT Hell

2009-10-06 Thread Matthew Croud


Okey Doke,

I'll try and be brief,
Well, my client agreed to a small online store that would hold the  
same stock items where only the quantities would differ, we agreed  
that, due to infrequent changes, I would make pages for any new items,  
and she would control stock etc using an e-shopping package I bought.


The site also has a page of Returned items, this takes the form of a  
Spry list, which uses an XML  list of clothing and their properties.

 It all worked great.

Yesterday my client said she wanted the ability to add, remove, edit  
new products by herself,  eek!
I thought about implementing another list similar to the returned  
items page, but I learned that XML will turn HTML elements like < and  
> into < and >


Then someone on this wonderful mailing list mentioned that HTML can be  
stored in XML using XSLT.


I suppose my question is, to what extend can XSLT decorate and display  
an XML file, can I add style sheets and rollovers, can I control the  
cacheing so that users wont need to empty their cache to see changed  
results ? Does it all work fine with PHP when I "include" it in a file ?


Sorry if this is a bit weird, but I'm bricking myself with this one,  
and I would just like to hear some voices from people who have been  
there and bought the t shirt,


Cheers folks!

Matt.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: How do YOU set default function/method params?

2009-10-06 Thread Al



Jim Lucas wrote:

Here is a problem that I have had for years now.  I have been trying to come up
with the perfect solution for this problem.  But, I have come down to two
different methods for solving it.

Here is the problem...

 date('c'),
'Message-ID' => md5($to.$subject),
);

$headers += $defaults;

END of examples...

Now, IMO, the last one is the simplest one and for me, I think it will be the
new way that I solve this type of problem.

But, my question that I put out to all of you is...

How would you solve this problem?

TIA

Jim Lucas


To me the key word in your question is "default". Here is a send mail example of 
how I do it. You'll see that I assign default stuff in the function. The all 
caps are constants set in my config file. For extremely high volume 
applications, one could memory cache the defaults.


I also use arrays assigned in my config file and then assign the array in the 
function using "global". When I do this, I immediately reassign the array so the 
function can't change the the assignments made in the config. e.g.,


function foo()
global booArray();

boo2Array= booArray(); Only use boo2Array() in the function.

function pearEmailSend($recipient, $emailSubj, $emailText, $applicEmailAddr)
{
$emailTo = $recipient;
$headers['From'] = $applicEmailAddr;
$headers['To'] = $emailTo;
if(!empty($emailCC)) $headers['Cc'] = $emailCC;
$headers['Return-Path'] = $applicEmailAddr; //or can use SMTP_USER; bounces 
are sent to applic address

$headers['Reply-To'] = $applicEmailAddr;
$headers['X-miniReg'] = APPLIC_NAME;
$headers['Date'] = date('r');
$headers['Subject'] = $emailSubj;
$params['debug'] = EMAIL_DEBUG; //Careful, do not leave on, creates a nasty 
message for admins

$params['host'] = $_SERVER['SERVER_NAME'];
$params['auth'] = true; //binary, set in config; some servers require auth
$params["username"] = $applicEmailAddr; //was SMTP_USER; //If auth true, 
must have value

$params["password"] = SMTP_PW; //If auth true, must have value
$params["localhost"] = $_SERVER['SERVER_NAME'];
$params['persist'] = true; //Default true
$mail_object = @Mail::factory(EMAIL_MODE, $params);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Active Directory LDAP Help

2009-10-06 Thread Devendra Jadhav
Hi All,

I am new to LDAP.
I want to create user on AD(Active Directory)
I have written script to do same, but I am getting "Operations error"
even I am successfully connected to AD and bounded with correct username,
password.
Also where will I get all attributes with its meanign... which attributes
are compulsory... different types of objects like users, groups,
organizational units and their attributes ...
where will i get all this information?

Help appreciated.
Thank you.

-- 
Devendra Jadhav


Re: [PHP] Active Directory LDAP Help

2009-10-06 Thread Yves Premel-Cabic
Why don't you use linux solutions like RedHat Directory Server or 
Mandriva Directory Server instead? (LDAP based too)
These solutions are scalable, free & fully documented on the web, not 
like this shitty MS AD (but is there a non-shitty MS product :p)


This is also much more easier to debugg... (linux...)

Devendra Jadhav wrote:

Hi All,

I am new to LDAP.
I want to create user on AD(Active Directory)
I have written script to do same, but I am getting "Operations error"
even I am successfully connected to AD and bounded with correct username,
password.
Also where will I get all attributes with its meanign... which attributes
are compulsory... different types of objects like users, groups,
organizational units and their attributes ...
where will i get all this information?

Help appreciated.
Thank you.

  



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Bob McConnell
From: Joost [mailto:joost.t.h...@planet.nl] 
> "Daevid Vincent" wrote:
>>> From: Ben Dunlap [mailto:bdun...@agentintellect.com]

>   $a = $a++;

I just think this is an ambiguous line of code that wasn't thought
through. The presence of the postfix operator makes the result
undefined, no matter what language you are using. It will be an accident
if you get the results you are expecting.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi



> It will be an accident
> if you get the results you are expecting.

I agree that the operation is illogical, I must disagree about accidents.

In PHP that operation will mean assign to the new $a variable the value 
returned from the other $a variable before the increment.

There is no mystery here, imho.

Regards
  
_
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

Re: [PHP] Active Directory LDAP Help

2009-10-06 Thread Devendra Jadhav
The existing Infrastructure is ready. and now at this point of time this is
difficult to switch to the Linux based. I love linux but helpless now ...
There is not so much information available on php.net

On Tue, Oct 6, 2009 at 6:15 PM, Yves Premel-Cabic wrote:

> Why don't you use linux solutions like RedHat Directory Server or Mandriva
> Directory Server instead? (LDAP based too)
> These solutions are scalable, free & fully documented on the web, not like
> this shitty MS AD (but is there a non-shitty MS product :p)
>
> This is also much more easier to debugg... (linux...)
>
>
> Devendra Jadhav wrote:
>
>> Hi All,
>>
>> I am new to LDAP.
>> I want to create user on AD(Active Directory)
>> I have written script to do same, but I am getting "Operations error"
>> even I am successfully connected to AD and bounded with correct username,
>> password.
>> Also where will I get all attributes with its meanign... which attributes
>> are compulsory... different types of objects like users, groups,
>> organizational units and their attributes ...
>> where will i get all this information?
>>
>> Help appreciated.
>> Thank you.
>>
>>
>>
>
>


-- 
Devendra Jadhav


Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Paul M Foster
On Tue, Oct 06, 2009 at 08:51:17AM -0400, Bob McConnell wrote:

> From: Joost [mailto:joost.t.h...@planet.nl] 
> > "Daevid Vincent" wrote:
> >>> From: Ben Dunlap [mailto:bdun...@agentintellect.com]
> 
> > $a = $a++;
> 
> I just think this is an ambiguous line of code that wasn't thought
> through. The presence of the postfix operator makes the result
> undefined, no matter what language you are using. It will be an accident
> if you get the results you are expecting.

The behavior of the ++ operator is the invention of Kernighan and Ritchie.
I don't imagine they ever foresaw anyone doing something as silly as

a = a++;

except under the rarest of circumstances.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Martin Scotta
On Tue, Oct 6, 2009 at 10:28 AM, Paul M Foster wrote:

> On Tue, Oct 06, 2009 at 08:51:17AM -0400, Bob McConnell wrote:
>
> > From: Joost [mailto:joost.t.h...@planet.nl]
> > > "Daevid Vincent" wrote:
> > >>> From: Ben Dunlap [mailto:bdun...@agentintellect.com]
> >
> > > $a = $a++;
> >
> > I just think this is an ambiguous line of code that wasn't thought
> > through. The presence of the postfix operator makes the result
> > undefined, no matter what language you are using. It will be an accident
> > if you get the results you are expecting.
>
> The behavior of the ++ operator is the invention of Kernighan and Ritchie.
> I don't imagine they ever foresaw anyone doing something as silly as
>
> a = a++;
>
> except under the rarest of circumstances.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
No matter how silly it can looks like (a = a++) it is still completely valid
code and it SHOULD run without problems.
If we analyse any portion of code (like a simple assigment) out of context
it'll always looks like this, just silly (in this case it's really really
silly).

One point here, that nobody mention, is the side effect.
++$i has a totaly different side effect than $i++

Sometimes you don't need the side effect but in other situations it really
matter.
Does these behaves exactly?
for($i=0; $i<10; ++$i)
for($i=0; $i<10; $i++)

There is no side effect on the incremental section because the result is not
evaluated.

and what about these?
$array[ $index++ ] = $elem;
$array[ ++$index ] = $elem;

You can read more about the side effect at
http://en.wikipedia.org/wiki/Side_effect_%28computer_science%29

-- 
Martin Scotta


RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi


> Does these behaves exactly?
> for($i=0; $i<10; ++$i)
> for($i=0; $i<10; $i++)

different benchmarks showed ++$i is usually faster than $i++
In that loop case, yes, what's happen internally is exactly the same, $i will 
be from 0 to 9, in the other case obviously is not the same.

but pre increment and post increment are truly basic stuff ... I don-t see all 
this need to study the case, it's pretty simple, as is that operation, in PHP.

In other languages, could have been the same, rarely in scripting languages 
though, at least those with still primitive scalar values (int, float, string, 
bool)

Regards
  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

Re: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Tom Worster
On 10/6/09 4:16 AM, "Mert Oztekin"  wrote:

> My mistake,
> 
> I thought it was date() now strftime()
> Sorry
> 
> (why do php developers create two different standarts for such similiar
> functions???☺ )
> 

it's traditional to do so. it reminds me of the bit about subtly
incompatible shells in unix from "Real Programmers Don't Use Pascal":

"Even Unix might not be as bad on Real Programmers as it once was. The
latest release of Unix has the potential of an operating system worthy of
any Real Programmer-- two different and subtly incompatible user interfaces,
an arcane and complicated teletype driver, virtual memory. If you ignore the
fact that it's "structured", even 'C' programming can be appreciated by the
Real Programmer: after all, there's no type checking, variable names are
seven (ten? eight?) characters long, and the added bonus of the Pointer data
type is thrown in-- like having the best parts of Fortran and assembly
language in one place. (Not to mention some of the more creative uses for
#define.)"

we could collect a list:

gnu make vs bsd make
how many subtly different versions of grep are there?


but i'm, sure it's been done already and i guess it's off topic.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Display HTML in XSL Style Sheet

2009-10-06 Thread Matthew Croud

Hi,
Is there a way to store HTML in an XML file,
Access that node using XLST, and have it display as rendered html ?

So far my attempts either return the text equivalent of the html, with  
nothing rendered.


Cheers,
Matt.








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Fwd: [PHP] Sessions in databases]

2009-10-06 Thread Il pinguino volante

(There were some erroros in the previous email, I'm sorry)

Hi to all.

I have to realize an authentication system for a lot of users.

I heard that someone uses to store session states (?) into a database. I'd 
like to know how and, expecially, WHY to do it and what's would be better 
(considering that I CANNOT -d'oh!- edit the php.ini file).


Thanks in advance,
Alfio.  





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Display HTML in XSL Style Sheet

2009-10-06 Thread Ashley Sheridan
On Tue, 2009-10-06 at 15:10 +0100, Matthew Croud wrote:

> Hi,
> Is there a way to store HTML in an XML file,
> Access that node using XLST, and have it display as rendered html ?
> 
> So far my attempts either return the text equivalent of the html, with  
> nothing rendered.
> 
> Cheers,
> Matt.
> 
> 
> 
> 
> 
> 
> 
> 


XHTML is just XML, so yes you can. I think the XSLT you're looking for
would be something like  which should just mirror
what XML you have in your source document. So if the XML it is matching
and outputting is the HTML, it will show as HTML.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Sessions in databases

2009-10-06 Thread Il pinguino volante


Hi to all.

I have to realize an authentication system for a lot of users.

I heard that someone uses to store session states (?) to a database. I'd 
like to know how by expecially WHY doing that and what's would be better 
(considering that I can -d'oh!- touch the php.ini file).


Thanks in advance,
Alfio.  



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHPNW09

2009-10-06 Thread David Otton
Is anyone from the list heading to PHPNW this weekend?

Saturday:

Keynote: The Uncertainty Principle

Passing The Joel Test in the PHP world
SPL, not a bridge too far
Tools and Talent
The beauty and the beast – API documentation with phpDocumentor
Getting a website out of the door
Optimizing Your Frontend Performance
Making your life easier: Xdebug
Speeding up the snail and making Drupal scale
Building an Anti-CMS (and how it’s changed our web team)
Introduction to Yii
Getting Involved with the PHP Project
Integrating Zend Framework and symfony

Sunday:

Tokens and Lexemes
Everything you wanted to know about UTF-8
Intro to OOP with PHP
PHP 5.3 – Hot or Not?
jQuery

http://conference.phpnw.org.uk/phpnw09/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHPNW09

2009-10-06 Thread Ashley Sheridan
On Tue, 2009-10-06 at 16:34 +0100, David Otton wrote:

> Is anyone from the list heading to PHPNW this weekend?
> 
> Saturday:
> 
> Keynote: The Uncertainty Principle
> 
> Passing The Joel Test in the PHP world
> SPL, not a bridge too far
> Tools and Talent
> The beauty and the beast – API documentation with phpDocumentor
> Getting a website out of the door
> Optimizing Your Frontend Performance
> Making your life easier: Xdebug
> Speeding up the snail and making Drupal scale
> Building an Anti-CMS (and how it’s changed our web team)
> Introduction to Yii
> Getting Involved with the PHP Project
> Integrating Zend Framework and symfony
> 
> Sunday:
> 
> Tokens and Lexemes
> Everything you wanted to know about UTF-8
> Intro to OOP with PHP
> PHP 5.3 – Hot or Not?
> jQuery
> 
> http://conference.phpnw.org.uk/phpnw09/
> 


No, it is a little far out for me. Is there something similar in
Londinium?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] PHPNW09

2009-10-06 Thread David Otton
2009/10/6 Ashley Sheridan 

> No, it is a little far out for me. Is there something similar in Londinium?

Dozens, probably. Try the PHPLondon guys, and the PHP UK Conference for a start:

http://www.phplondon.org/wiki/Main_Page

http://www.phpconference.co.uk/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHPNW09

2009-10-06 Thread Daniel Brown
On Tue, Oct 6, 2009 at 11:34, Ashley Sheridan  wrote:
>
> No, it is a little far out for me. Is there something similar in
> Londinium?

Best way to keep informed is through php.net.  Don't make our
efforts be in vain!  ;-P

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How do YOU set default function/method params?

2009-10-06 Thread Jim Lucas
Mert Oztekin wrote:
> IMO, array_merge() is easy to use, however it suppose to use more cpu than 
> other options. If you are a performance freak, i suggest you to not choose 
> array_merge() solution. (also you execute date() and md5() functions even if 
> you wont need to use them)
> 
> In the other way, I think first option (with if() ones) seems more readable 
> than other ones.
> 

>From a performance view, check out these numbers

http://www.cmsws.com/examples/php/functions/speedtests/array_merge.php

To see the source:
http://www.cmsws.com/examples/php/functions/speedtests/array_merge.phps

What a surprising difference in numbers!!!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Display HTML in XSL Style Sheet

2009-10-06 Thread Lupus Michaelis

Matthew Croud wrote:

Is there a way to store HTML in an XML file,
Access that node using XLST, and have it display as rendered html ?


  As XHTML ypu can integrate it in an XML, by the use of XMLNS. But it 
is OT.

  In the XML, you declare two XMLNS. In the XSLT, you declare three XMLNS.

--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHPNW09

2009-10-06 Thread Daniel Brown
On Tue, Oct 6, 2009 at 11:34, David Otton
 wrote:
> Is anyone from the list heading to PHPNW this weekend?

Coincidentally, the PHPNW UG meeting is listed for tomorrow, but I
have no listing for a conference this weekend.  If you're in contact
with any of those folks, Dave, you can ask them to submit the
conference.

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd

At 3:56 PM +0200 10/6/09, Andrea Giammarchi wrote:

 > Does these behaves exactly?

 for($i=0; $i<10; ++$i)
 for($i=0; $i<10; $i++)


different benchmarks showed ++$i is usually faster than $i++


"Faster" is a relative term that is becoming more meaningless each year.

Considering that "speed" is increasing and "memory" prices are 
dropping exponentially, both of those are becoming less and less 
important in design considerations (my opinion).


The speeds of the Crays of yesteryear we are now holding in our hands 
as cell phones. The memory we are buying today is literally fractions 
of a cent of the tens of thousands of dollars we spent some 20 years 
ago.


I venture to claim the time it took me to write this email (and for 
you to read it) was longer than the total time saved between using 
++$i vs $i++ for all the php scripts in the world over the remaining 
life span of PHP.


Interesting "food for thought", huh?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Dynamic array creation and tracking

2009-10-06 Thread John Nichel
Howdy guys and girls.  Been a long time since I've been in these parts.
My php is rusty these days, so please bare with me.  I'm trying to
create a dynamic, multidimensional array, and keep track of which level
I'm on, opening and closing levels as needed.  Lets say that I have some
data like the below:

Array
(
[0] => Array
(
[tag] => OrderFeed
[type] => open
[level] => 1
[attributes] => Array
(
[version] => 1.0
)

[value] => -
)

[1] => Array
(
[tag] => Order
[type] => open
[level] => 2
[value] => -
)

[2] => Array
(
[tag] => OrderId
[type] => open
[level] => 3
)

[3] => Array
(
[tag] => E4XOrderId
[type] => complete
[level] => 4
[value] => E4X0001
)

[4] => Array
(
[tag] => MerchantOrderId
[type] => complete
[level] => 4
[value] => Mrc001
)

[5] => Array
(
[tag] => MerchantOrderRef
[type] => complete
[level] => 4
[value] => ABCDEFGHI01
)

[6] => Array
(
[tag] => OrderId
[type] => close
[level] => 3
)

[7] => Array
(
[tag] => Order
[value] => -
[type] => cdata
[level] => 2
)

[8] => Array
(
[tag] => OrderDate
[type] => open
[level] => 3
)

[9] => Array
(
[tag] => CreateDate
[type] => complete
[level] => 4
[value] => 12-03-2007
)

[10] => Array
(
[tag] => ExpiryDate
[type] => complete
[level] => 4
[value] => 12-15-2007
)
)

I create an empty array before I start looping through this data:

$newArray = array();

Now, when looping through the data, every time I encounter a 'tag' that
is of the open 'type' I need to create a new array within the base array
with the value of 'tag' as the index:

$newArray['OrderFeed']
$newArray['OrderFeed']['Order']
$newArray['OrderFeed']['Order']['OrderID']

So on and so forth.  When I get to a 'tag' that is of the 'type'
complete, I need to make that a name value pair in the current level of
the array:

Array
(
[OrderFeed] => Array
(
[Order] = Array
(
[OrderID] = Array
(
[CreateDate] => 12-03-2007
)
)
)
)

And when I get to 'tag' of the close 'type', I need to move up one level
in the array.  I have tried using another array just to keep track of
what level of the array I'm currently on, but I can seem to figure out
how to form the master array out of it.  In the above example, I would
have an array with the 'OrderFeed', 'Order' and 'OrderID' as the three
elements in it.  If I encounter and 'open' tag, I add that value onto
the end of the 'tracking' array, and when I encounter a 'close' tag, I
just pop the last element off of the tracking array.  So basically, I'm
trying to take the values in my 'tracking' array

Array
(
OrderFeed,
Order,
OrderID
)

And somehow, use them to keep track of where I am in the dynamic
$newArray.  I hope this makes senseI know what I want to do in my
head, but I'm not sure I'm getting it out well here.  Any suggestions?
Questions?

--
John C. Nichel IV
System Administrator
KegWorks
http://www.kegworks.com
716.362.9212 x16
j...@kegworks.com 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Time Problem: always ten past xx

2009-10-06 Thread tedd

At 10:07 AM +0200 10/6/09, Matthias Laug wrote:

argh, why do I always stick to the stupid questions :( sorry


Because with the important questions, you don't need answers. You 
understand them.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi

er ... tedd, whatever, usually ++i is faster in almost every language, and even 
C developers could use these kind of micro optimizations.

Speed, even in this SuperCPU era, is still relevant, we would not need 
benchmark to compare programming languages for each purpose.

Of course in a crappy application, the usage of ++i rather than i++ won't make 
any difference, but specially for that kind of for loop where there is 
absolutely no harm or side-effect using ++i rather than i++ ... if ++i could be 
0.0001% nobody have a valid reason to avoid it.

Put in this way: I need to do the same thing, one could be better ... why on 
earth should I use the other way?

I just develop applications, where I can micro-optimize, I do it ... I have 
never had speed problems, but maybe I am just lucky.

Regards

> Date: Tue, 6 Oct 2009 12:15:54 -0400
> To: php-general@lists.php.net
> From: tedd.sperl...@gmail.com
> Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo
> 
> At 3:56 PM +0200 10/6/09, Andrea Giammarchi wrote:
> >  > Does these behaves exactly?
> >>  for($i=0; $i<10; ++$i)
> >>  for($i=0; $i<10; $i++)
> >
> >different benchmarks showed ++$i is usually faster than $i++
> 
> "Faster" is a relative term that is becoming more meaningless each year.
> 
> Considering that "speed" is increasing and "memory" prices are 
> dropping exponentially, both of those are becoming less and less 
> important in design considerations (my opinion).
> 
> The speeds of the Crays of yesteryear we are now holding in our hands 
> as cell phones. The memory we are buying today is literally fractions 
> of a cent of the tens of thousands of dollars we spent some 20 years 
> ago.
> 
> I venture to claim the time it took me to write this email (and for 
> you to read it) was longer than the total time saved between using 
> ++$i vs $i++ for all the php scripts in the world over the remaining 
> life span of PHP.
> 
> Interesting "food for thought", huh?
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
  
_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009

Re: [Fwd: [PHP] Sessions in databases]

2009-10-06 Thread Sam Stelfox
If you are distributing your application over multiple servers, using a 
database for session tracking allows a user to continue there session 
regardless of which server their request bounces too. It prevents the 
need for 'sticky' network connections which time out anyways. Databases 
can make scaling applications to enterprise size considerably easier. 
There are other file based solutions that are dirty and require you to 
play with file locking and all that nastyness.


You also don't need access to the php.ini file to implement session in a 
database, check out http://php.net/session_set_save_handler


Il pinguino volante wrote:

(There were some erroros in the previous email, I'm sorry)

Hi to all.

I have to realize an authentication system for a lot of users.

I heard that someone uses to store session states (?) into a database. 
I'd like to know how and, expecially, WHY to do it and what's would be 
better (considering that I CANNOT -d'oh!- edit the php.ini file).


Thanks in advance,
Alfio. 







--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Dynamic array creation and tracking

2009-10-06 Thread tedd

At 12:18 PM -0400 10/6/09, John Nichel wrote:

Howdy guys and girls.  Been a long time since I've been in these parts.
My php is rusty these days, so please bare with me.  I'm trying to
create a dynamic, multidimensional array, and keep track of which level
I'm on, opening and closing levels as needed.  Lets say that I have some
data like the below:


Hi John:

Not that it matters, but I remember you. You left the list a couple 
of years ago. But only after you publicly stated that you added me to 
your kill file because I asked a question in a manner that you didn't 
approve. Well, I hope those days are past -- we're usually bit more 
understanding and less confrontational on this list now. The idea 
here is to help -- so, welcome to the list.


What you are asking is much like parsing an xml file. I don't know 
where you're getting your data, you didn't say other than you 
mentioned "tags", but you might find this of help:


http://www.php.net/xml

and more specifically:

http://www.php.net/manual/en/example.xml-structure.php

That seems to mimic what you are trying to do.

As far as keeping track of what level you're on, there are several 
Parser functions to explore such as byte_index, line_number, and 
column_number. Perhaps those will help.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Active Directory LDAP Help

2009-10-06 Thread Tommy Pham
- Original Message 
> From: Devendra Jadhav 
> To: Yves Premel-Cabic 
> Cc: php-general@lists.php.net
> Sent: Tue, October 6, 2009 6:18:13 AM
> Subject: Re: [PHP] Active Directory LDAP Help
> 
> The existing Infrastructure is ready. and now at this point of time this is
> difficult to switch to the Linux based. I love linux but helpless now ...
> There is not so much information available on php.net
> 
> On Tue, Oct 6, 2009 at 6:15 PM, Yves Premel-Cabic wrote:
> 
> > Why don't you use linux solutions like RedHat Directory Server or Mandriva
> > Directory Server instead? (LDAP based too)
> > These solutions are scalable, free & fully documented on the web, not like
> > this shitty MS AD (but is there a non-shitty MS product :p)
> >
> > This is also much more easier to debugg... (linux...)
> >
> >
> > Devendra Jadhav wrote:
> >
> >> Hi All,
> >>
> >> I am new to LDAP.
> >> I want to create user on AD(Active Directory)
> >> I have written script to do same, but I am getting "Operations error"
> >> even I am successfully connected to AD and bounded with correct username,
> >> password.
> >> Also where will I get all attributes with its meanign... which attributes
> >> are compulsory... different types of objects like users, groups,
> >> organizational units and their attributes ...
> >> where will i get all this information?
> >>
> >> Help appreciated.
> >> Thank you.
> >>
> >>
> >>
> >
> >
> 
> 
> -- 
> Devendra Jadhav

Devendra,

Are you trying to create a web UI to manage AD accounts?  If so, I hope you 
know that you're reinventing the wheel.  Have a look at phpldapadmin at 
http://phpldapadmin.sourceforge.net/

Regards,
Tommy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Eddie Drapkin
On Tue, Oct 6, 2009 at 12:25 PM, Andrea Giammarchi  wrote:
>
> er ... tedd, whatever, usually ++i is faster in almost every language, and 
> even C developers could use these kind of micro optimizations.
>
> Speed, even in this SuperCPU era, is still relevant, we would not need 
> benchmark to compare programming languages for each purpose.
>
> Of course in a crappy application, the usage of ++i rather than i++ won't 
> make any difference, but specially for that kind of for loop where there is 
> absolutely no harm or side-effect using ++i rather than i++ ... if ++i could 
> be 0.0001% nobody have a valid reason to avoid it.
>
> Put in this way: I need to do the same thing, one could be better ... why on 
> earth should I use the other way?
>
> I just develop applications, where I can micro-optimize, I do it ... I have 
> never had speed problems, but maybe I am just lucky.
>
> Regards
>
>> Date: Tue, 6 Oct 2009 12:15:54 -0400
>> To: php-general@lists.php.net
>> From: tedd.sperl...@gmail.com
>> Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo
>>
>> At 3:56 PM +0200 10/6/09, Andrea Giammarchi wrote:
>> >  > Does these behaves exactly?
>> >>  for($i=0; $i<10; ++$i)
>> >>  for($i=0; $i<10; $i++)
>> >
>> >different benchmarks showed ++$i is usually faster than $i++
>>
>> "Faster" is a relative term that is becoming more meaningless each year.
>>
>> Considering that "speed" is increasing and "memory" prices are
>> dropping exponentially, both of those are becoming less and less
>> important in design considerations (my opinion).
>>
>> The speeds of the Crays of yesteryear we are now holding in our hands
>> as cell phones. The memory we are buying today is literally fractions
>> of a cent of the tens of thousands of dollars we spent some 20 years
>> ago.
>>
>> I venture to claim the time it took me to write this email (and for
>> you to read it) was longer than the total time saved between using
>> ++$i vs $i++ for all the php scripts in the world over the remaining
>> life span of PHP.
>>
>> Interesting "food for thought", huh?
>>
>> Cheers,
>>
>> tedd
>>
>> --
>> ---
>> http://sperling.com  http://ancientstones.com  http://earthstones.com
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> _
> Windows Live: Make it easier for your friends to see what you’re up to on 
> Facebook.
> http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009

The problem with PHP micro-optimizations like that or ' vs. " is that
PHP rarely bottlenecks a PHP/MySQL application (actually if you run a
dedicated box, see how often your CPU hits 100%, it won't be very
often for the vast majority of PHP/MySQL sites which are more likely
to be disk i/o bound than cpu bound).  The time spent in PHP (by PHP,
not by the database) for page generation is completely negligible and
invisible behind the overhead of network protocols for the vast
majority of sites or drowned in the performance killing of SQL.  I
would probably go so far as to say it doesn't matter how quickly your
PHP runs; you'd save as much time tuning one slow query as you would
micro-optimizing every line of your codebase.  Furthermore, the amount
of time micro-optimization takes up (going through old code, I mean)
could be better spent doing something that actually does increase your
performance, like implementing a search engine or memcached.  Going
forward, if you're aware that ++i and i++ are the same for your
application and ++i is a single php opcode faster (which I don't know
if it's even measurable, that difference), sure go ahead and use ++i
but it's certainly not worth serious thought or developer time.

My two cents.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Spry, XML, PHP and XSLT Hell

2009-10-06 Thread Tommy Pham
- Original Message 
> From: Matthew Croud 
> To: PHP General list 
> Sent: Tue, October 6, 2009 1:32:18 AM
> Subject: [PHP] Spry, XML, PHP and XSLT Hell
> 
> 
> Okey Doke,
> 
> I'll try and be brief,
> Well, my client agreed to a small online store that would hold the same stock 
> items where only the quantities would differ, we agreed that, due to 
> infrequent 
> changes, I would make pages for any new items, and she would control stock 
> etc 
> using an e-shopping package I bought.
> 
> The site also has a page of Returned items, this takes the form of a Spry 
> list, 
> which uses an XML  list of clothing and their properties.
> It all worked great.
> 

If my memory serves, you're using PHP to generate the XML for Spry list using 
data from DB backend?  Or is your data in XML file(s) and not DB?

> Yesterday my client said she wanted the ability to add, remove, edit new 
> products by herself,  eek!
> I thought about implementing another list similar to the returned items page, 
> but I learned that XML will turn HTML elements like < and > into < and >

You could add a unique URL (based on product ID) of each product ID to row in 
the list.  The link would point to another page where your client can 
add/update the data.  Or if you really want to do AJAX way, clicking the link 
would show a hidden  for add/update depending on what link is clicked.  
Doing via AJAX means you'll have to add some javascript code of your own to 
tell Spry to refresh the data for the list and refresh the display results.

> 
> Then someone on this wonderful mailing list mentioned that HTML can be stored 
> in 
> XML using XSLT.
> 
> I suppose my question is, to what extend can XSLT decorate and display an XML 
> file, can I add style sheets and rollovers, can I control the cacheing so 
> that 
> users wont need to empty their cache to see changed results ? Does it all 
> work 
> fine with PHP when I "include" it in a file ?

FYI, caching is messy when you may have concurrent users adding/updating the 
data.

Regards,
Tommy

> 
> Sorry if this is a bit weird, but I'm bricking myself with this one, and I 
> would 
> just like to hear some voices from people who have been there and bought the 
> t 
> shirt,
> 
> Cheers folks!
> 
> Matt.
> 
> 
> 
> --PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd

At 6:25 PM +0200 10/6/09, Andrea Giammarchi wrote:
er ... tedd, whatever, usually ++i is faster in almost every 
language, and even C developers could use these kind of micro 
optimizations.


Speed, even in this SuperCPU era, is still relevant, we would not 
need benchmark to compare programming languages for each purpose.


Of course in a crappy application, the usage of ++i rather than i++ 
won't make any difference, but specially for that kind of for loop 
where there is absolutely no harm or side-effect using ++i rather 
than i++ ... if ++i could be 0.0001% nobody have a valid reason to 
avoid it.


Put in this way: I need to do the same thing, one could be better 
... why on earth should I use the other way?


I just develop applications, where I can micro-optimize, I do it ... 
I have never had speed problems, but maybe I am just lucky.


Andrea:

I think you missed my point.

First, you do whatever you want -- do you whatever makes you feel 
comfortable. I'm not trying to change your ways at all.


Second, to the contrary -- all I am saying is if you have a 
preference in using ++$i or $i++, then use it. But to say the reason 
why you use it is because of speed is becoming less of an issue than 
it was. So much so, that for people to argue either side is rather 
pointless. There is no significant difference.


Sure we will continue to benchmark the speed of different languages 
for comparisons, we have a long history/habit of doing that. But that 
too is becoming less important than it was for what was significant 
yesterday is not significant today and will be even less so tomorrow.


For example, the Human Gnome Project was first thought to be a 
project that would take at least 15 years, but it was finished in 5. 
Why? Because the original projections were based upon the computing 
power of the day and didn't take into account advances in speed and 
memory.


So while we can debate computing considerations of today, tomorrow 
those will be less important. That was the point I was making. Why 
not focus on things that make significant difference and let the 
insignificant fade into history.


Look on the bright side, you can tell your grand children "I remember 
when ++i was faster than i++" and they'll wonder if Mom and Dad were 
right when they talked about putting you in a rest home.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Jay Blanchard
[snip]
...micro optimizations...
[/snip]

And in the land of micro optimization you would likely never see the
following;

$a = $a++;

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd


The problem with PHP micro-optimizations like that or ' vs. " is that
PHP rarely bottlenecks a PHP/MySQL application (actually if you run a
dedicated box, see how often your CPU hits 100%, it won't be very
often for the vast majority of PHP/MySQL sites which are more likely
to be disk i/o bound than cpu bound).  The time spent in PHP (by PHP,
not by the database) for page generation is completely negligible and
invisible behind the overhead of network protocols for the vast
majority of sites or drowned in the performance killing of SQL.  I
would probably go so far as to say it doesn't matter how quickly your
PHP runs; you'd save as much time tuning one slow query as you would
micro-optimizing every line of your codebase.  Furthermore, the amount
of time micro-optimization takes up (going through old code, I mean)
could be better spent doing something that actually does increase your
performance, like implementing a search engine or memcached.  Going
forward, if you're aware that ++i and i++ are the same for your
application and ++i is a single php opcode faster (which I don't know
if it's even measurable, that difference), sure go ahead and use ++i
but it's certainly not worth serious thought or developer time.

My two cents.


Eddie:

And thanks for supporting my point.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd

At 12:46 PM -0500 10/6/09, Jay Blanchard wrote:

[snip]
...micro optimizations...
[/snip]

And in the land of micro optimization you would likely never see the
following;

$a = $a++;


I must live in the land of micro optimization.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Spry, XML, PHP and XSLT Hell

2009-10-06 Thread Tommy Pham
- Original Message 
> From: Tommy Pham 
> To: PHP General list 
> Sent: Tue, October 6, 2009 10:41:42 AM
> Subject: Re: [PHP] Spry, XML, PHP and XSLT Hell
> 
> - Original Message 
> > From: Matthew Croud 
> > To: PHP General list 
> > Sent: Tue, October 6, 2009 1:32:18 AM
> > Subject: [PHP] Spry, XML, PHP and XSLT Hell
> > 
> > 
> > Okey Doke,
> > 
> > I'll try and be brief,
> > Well, my client agreed to a small online store that would hold the same 
> > stock 
> > items where only the quantities would differ, we agreed that, due to 
> infrequent 
> > changes, I would make pages for any new items, and she would control stock 
> > etc 
> 
> > using an e-shopping package I bought.
> > 
> > The site also has a page of Returned items, this takes the form of a Spry 
> list, 
> > which uses an XML  list of clothing and their properties.
> > It all worked great.
> > 
> 
> If my memory serves, you're using PHP to generate the XML for Spry list using 
> data from DB backend?  Or is your data in XML file(s) and not DB?
> 
> > Yesterday my client said she wanted the ability to add, remove, edit new 
> > products by herself,  eek!
> > I thought about implementing another list similar to the returned items 
> > page, 
> > but I learned that XML will turn HTML elements like < and > into < and >
> 
> You could add a unique URL (based on product ID) of each product ID to row in 
> the list.  The link would point to another page where your client can 
> add/update 
> the data.  Or if you really want to do AJAX way, clicking the link would show 
> a 
> hidden 
for add/update depending on what link is clicked.  Doing via AJAX 
> means you'll have to add some javascript code of your own to tell Spry to 
> refresh the data for the list and refresh the display results.
> 

I forgot to mention that in addition to the javascript code, you still have to 
validate and sanitize user input in PHP.  So might as well just have the link 
point to another page and do it there.  Upon successful update, you can 
redirect back the Spry list page.

> > 
> > Then someone on this wonderful mailing list mentioned that HTML can be 
> > stored 
> in 
> > XML using XSLT.
> > 
> > I suppose my question is, to what extend can XSLT decorate and display an 
> > XML 
> > file, can I add style sheets and rollovers, can I control the cacheing so 
> > that 
> 
> > users wont need to empty their cache to see changed results ? Does it all 
> > work 
> 
> > fine with PHP when I "include" it in a file ?
> 
> FYI, caching is messy when you may have concurrent users adding/updating the 
> data.
> 
> Regards,
> Tommy
> 
> > 
> > Sorry if this is a bit weird, but I'm bricking myself with this one, and I 
> would 
> > just like to hear some voices from people who have been there and bought 
> > the t 
> 
> > shirt,
> > 
> > Cheers folks!
> > 
> > Matt.
> > 
> > 
> > 
> > --PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd

At 10:48 AM -0300 10/6/09, Martin Scotta wrote:

No matter how silly it can looks like (a = a++) it is still completely valid
code and it SHOULD run without problems.


Yeah, it's a valid as:

   $a = $a;

and does the same thing, which is nothing.

If you want a statement that does something, then use:

  $a = ++$a;

or simply:

  $a++;

or

  ++$a;

Any of those will increment $a, whereas ($a = $a++;) does nothing.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Tommy Pham
- Original Message 
> From: tedd 
> To: Martin Scotta ; Paul M Foster 
> 
> Cc: php-general@lists.php.net
> Sent: Tue, October 6, 2009 11:08:14 AM
> Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo
> 
> At 10:48 AM -0300 10/6/09, Martin Scotta wrote:
> > No matter how silly it can looks like (a = a++) it is still completely valid
> > code and it SHOULD run without problems.
> 
> Yeah, it's a valid as:
> 
>$a = $a;
> 
> and does the same thing, which is nothing.
> 
> If you want a statement that does something, then use:
> 
>   $a = ++$a;
> 
> or simply:
> 
>   $a++;
> 
> or
> 
>   ++$a;
> 
> Any of those will increment $a, whereas ($a = $a++;) does nothing.
> 
> Cheers,
> 
> tedd
> 
> -- ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> -- PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

I find it interesting for a discussion to go on this long for something as
$a = $a++;
which should have never happened in the first place ;)

Regards,
Tommy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd

At 11:11 AM -0700 10/6/09, Tommy Pham wrote:


I find it interesting for a discussion to go on this long for something as
$a = $a++;
which should have never happened in the first place ;)

Regards,
Tommy


Hey, we're programmers. We waste time for a living.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Jay Blanchard
[snip]
I find it interesting for a discussion to go on this long for something
as
$a = $a++;
[/snip]

You think that is interesting? Start a conversation about these 

{}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [Fwd: [PHP] Sessions in databases]

2009-10-06 Thread Tom Worster
On 10/6/09 10:26 AM, "Il pinguino volante"  wrote:

> I have to realize an authentication system for a lot of users.
> 
> I heard that someone uses to store session states (?) into a database. I'd
> like to know how and, expecially, WHY to do it and what's would be better
> (considering that I CANNOT -d'oh!- edit the php.ini file).

i think you can modify the PHP session handler without touching php.ini:
http://www.php.net/manual/en/function.session-set-save-handler.php

i've read a lot on the web about this in recent weeks. different people
offer their own justifications for the various approaches to session
handling: PHP's file handler, user DB methods for the PHP session handler,
PHP's memcache handler, zend session clustering, or do it yourself and don't
use PHP sessions at all.

there's a lot of controversy on the topic because different people have
different requirements and preferences. so your question WHY? is quite
complex.

my motivation for considering user DB back-end to the PHP session handler
was that it would replicate the session data over the DB cluster. retaining
the PHP session front-end means less code rework and you keep its session
locking. but it adds DB load, and the DB is often an app's bottleneck.
whether or not that's ok depends on app specifics.

i looked at memcache but i have two problems with it. one is that it is a
cache system so it's not designed to be reliable: if it runs out of memory,
restarts or crashes, the sessions are gone. the other is that the PHP
session implementation is barely documented. i couldn't figure out how it
implements the clustering (does it?) so i couldn't see how i would implement
failover, recovery and maintenance procedures.
http://phpslacker.com/2009/03/02/php-session-clustering-with-memcache/

one class i saw used memcached combined with DB in case of cache miss. it
speeds up the reads but every write goes to both cache and DB.

one thing that obviously helps is don't write the session to the DB if it
hasn't changed. i'm not sure how best to do that yet. and you can optimize
the writing of the session timestamp to the DB too.

then there's the question of whether or not to use one DB connection for
both session handling and the main app or use two connections. the latter is
easier to code.

row locking in the session table would be preferable to table locking.

maybe we should work together on the code for all this?

there's a webinar on zend platform session clustering that discusses various
issues, bearing in mind it's a technical sales pitch. i don't think it's
entirely fair to the DB methods.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Self-Process php forms or not?

2009-10-06 Thread Philip Thompson

On Oct 5, 2009, at 7:42 PM, Manuel Lemos wrote:


Hello,

on 10/05/2009 03:02 PM Philip Thompson said the following:

I try to avoid the use of hidden form elements as much as possible,
especially for tracking whether a user has submitted a form or  
not...


I use name="submit" for the submit button instead, that will pass  
the

value of the submit button to the action script.

above all i use a template engine, smarty to take care of the
presentation for me(like deciding whether to show the form and/or a
success/failure message)


That only works if the user clicks on that submit button. If the  
user
hits the enter key in a text input, the form is submitted but the  
submit

input variable is not set. That is why an hidden input is a safer
solution.


If you need the button to be *clicked*...



Or something along those lines.


That does not make much sense and is pointless. First that syntax you
mentioned probably requires JQuery or some other large Javascript
library. something like this['submitButton'].click() would emulate the
click event. Second, by the time that onsubmit is called, the event  
that

triggered it was already dispatched. Emulating the click on a button
would probably fire the form submission and onsubmit code would be run
again, leading to an infinite loop sucking machine CPU.


It makes perfect sense and is not pointless. Yes, it is library- 
specific javascript. However, it was used to show an example and make  
a point. I assume that most the subscribers here are able to decipher  
the code and determine what the intent was. And no, this will not  
cause an infinite loop. The onsubmit is called first and will process  
whatever action you specify, and then move on. *If* the submit button  
wasn't *clicked* and you needed it to be, then this would emulate that  
functionality. I'm not saying this is the best solution on how to deal  
with the previous question but it is *a* solution.


Here's some code that you can see there's no infinite loop and shows  
which events are called first.


--



loop? i don't think so


Times submitted: 

name="theForm" onsubmit="document.getElementById('submitBtn').click();  
return false;">


>




document.theForm.text.focus();


--

The above code works as expected in Safari 4.0.3, FF3.5.3 and IE8.

Cheers,
~Philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ternary operator sintax help

2009-10-06 Thread MEM
Hello all,

I'm trying to display a div, only when some php value is set.
Since this will be near html, I'd like to keep it on one line. So, I'd love
to use shortcuts and a ternary operator for the effect.

I'm having something like this right now, but the div still appears even if
the error is NOT set.

'
.$erros['anexo'].'' :''; ?>

:( 

Can I have your help with the right syntax ?


Regards,
The newbie on a Humpty Dumpty wall,
Márcio


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Ashley Sheridan
On Tue, 2009-10-06 at 13:34 -0500, Jay Blanchard wrote:

> [snip]
> I find it interesting for a discussion to go on this long for something
> as
> $a = $a++;
> [/snip]
> 
> You think that is interesting? Start a conversation about these 
> 
> {}
> 


Now they actually make sense! I've used those as placeholders in
scripts, should I foresee an area where something may be expanded in the
future.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Israel Ekpo
On Tue, Oct 6, 2009 at 2:34 PM, Jay Blanchard  wrote:

> [snip]
> I find it interesting for a discussion to go on this long for something
> as
> $a = $a++;
> [/snip]
>
> You think that is interesting? Start a conversation about these
>
> {}
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
You guys are very funny!

Its very funny how so many people are fired up and ready to strike by
something this miniscule.

Speaking of starting a conversation, what do you think about the "goto"
construct introduced just recently?

-- 
"Good Enough" is not good enough.
To give anything less than your best is to sacrifice the gift.
Quality First. Measure Twice. Cut Once.


Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Daniel Brown
On Tue, Oct 6, 2009 at 14:46, Israel Ekpo  wrote:
>
> Speaking of starting a conversation, what do you think about the "goto"
> construct introduced just recently?

Better yet: what do you all think of folks hijacking threads?

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers?  Ask me how we can fit your budget!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ternary operator sintax help

2009-10-06 Thread Jo�o C�ndido de Souza Neto
'.$erros['anexo'].'' :''); ?>

""MEM""  escreveu na mensagem 
news:002401ca46b4$ed6ad6a0$c84083...@com...
Hello all,

I'm trying to display a div, only when some php value is set.
Since this will be near html, I'd like to keep it on one line. So, I'd love
to use shortcuts and a ternary operator for the effect.

I'm having something like this right now, but the div still appears even if
the error is NOT set.

'
.$erros['anexo'].'' :''; ?>

:(

Can I have your help with the right syntax ?


Regards,
The newbie on a Humpty Dumpty wall,
Márcio



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: JM.PHP.NET

2009-10-06 Thread Daniel Brown
On Tue, Oct 6, 2009 at 14:56, Dan Papakonstantino  wrote:
> Hello Dan,
>
> Sorry for the misunderstanding however, we are web developers as well as 
> hardware and software developers. You may have overlooked our web based 
> timesheet application called SonicWeb. Please review the following link on 
> our website under the heading "Web".

I did not overlook anything, and that is not at all the kind of
institution or organization we want to sponsor mirrors, thank you.
You may be web developers, but the site you submitted is selling a
product that works on the web.  It's against our policy.

Your application has been rejected.  Thank you.

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] ternary operator sintax help

2009-10-06 Thread MEM
Thanks. I will give up on 
 
I mean, it will show the message only when the form gets submitted. At the 
beginning it will have ‘’. 
 
:s
 
Regards,
Marcio
 
 
 
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: terça-feira, 6 de Outubro de 2009 19:49
To: MEM
Cc: php-general@lists.php.net
Subject: Re: [PHP] ternary operator sintax help
 
On Tue, 2009-10-06 at 19:43 +0100, MEM wrote: 
 
Hello all,
 
I'm trying to display a div, only when some php value is set.
Since this will be near html, I'd like to keep it on one line. So, I'd love
to use shortcuts and a ternary operator for the effect.
 
I'm having something like this right now, but the div still appears even if
the error is NOT set.
 
'
.$erros['anexo'].'' :''; ?>
 
:( 
 
Can I have your help with the right syntax ?
 
 
Regards,
The newbie on a Humpty Dumpty wall,
Márcio
 
 

Firstly, http://www.ashleysheridan.co.uk


 


Re: [PHP] ternary operator sintax help

2009-10-06 Thread Ashley Sheridan
On Tue, 2009-10-06 at 19:43 +0100, MEM wrote:

> Hello all,
> 
> I'm trying to display a div, only when some php value is set.
> Since this will be near html, I'd like to keep it on one line. So, I'd love
> to use shortcuts and a ternary operator for the effect.
> 
> I'm having something like this right now, but the div still appears even if
> the error is NOT set.
> 
> '
> .$erros['anexo'].'' :''; ?>
> 
> :( 
> 
> Can I have your help with the right syntax ?
> 
> 
> Regards,
> The newbie on a Humpty Dumpty wall,
> Márcio
> 
> 


Firstly, http://www.ashleysheridan.co.uk




RE: [PHP] Re: ternary operator sintax help

2009-10-06 Thread MEM
Sorry all,
It's ok. The sintax:

'.$erros['anexo'].'' :''); ?>

Was right all the time. 

Anyway, I've learn something new: having a var with '' is not the same thing
as not been unset. So we must pay attention on what cases we use isset, or
!empty.


Thanks a lot,
Márcio

> -Original Message-
> From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br]
> Sent: terça-feira, 6 de Outubro de 2009 19:53
> To: php-general@lists.php.net
> Subject: [PHP] Re: ternary operator sintax help
> 
>  class="mensagemErro">'.$erros['anexo'].'' :''); ?>
> 
> ""MEM""  escreveu na mensagem
> news:002401ca46b4$ed6ad6a0$c84083...@com...
> Hello all,
> 
> I'm trying to display a div, only when some php value is set.
> Since this will be near html, I'd like to keep it on one line. So, I'd
> love
> to use shortcuts and a ternary operator for the effect.
> 
> I'm having something like this right now, but the div still appears
> even if
> the error is NOT set.
> 
> '
> .$erros['anexo'].'' :''; ?>
> 
> :(
> 
> Can I have your help with the right syntax ?
> 
> 
> Regards,
> The newbie on a Humpty Dumpty wall,
> Márcio
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: ternary operator sintax help

2009-10-06 Thread Philip Thompson

On Oct 6, 2009, at 2:26 PM, MEM wrote:


Sorry all,
It's ok. The sintax:

'.$erros['anexo'].'' :''); ?>

Was right all the time.

Anyway, I've learn something new: having a var with '' is not the  
same thing
as not been unset. So we must pay attention on what cases we use  
isset, or

!empty.


Thanks a lot,
Márcio


-Original Message-
From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br]
Sent: terça-feira, 6 de Outubro de 2009 19:53
To: php-general@lists.php.net
Subject: [PHP] Re: ternary operator sintax help

'.$erros['anexo'].'' :''); ?>

""MEM""  escreveu na mensagem
news:002401ca46b4$ed6ad6a0$c84083...@com...
Hello all,

I'm trying to display a div, only when some php value is set.
Since this will be near html, I'd like to keep it on one line. So,  
I'd

love
to use shortcuts and a ternary operator for the effect.

I'm having something like this right now, but the div still appears
even if
the error is NOT set.

'
.$erros['anexo'].'' :''; ?>

:(

Can I have your help with the right syntax ?


Another one to consider...

strlen ($item) > 0 ? 'not empty' : 'empty';

Because "empty()" will return true if 0 is the value, sometimes you  
have to check for the length of the item.


~Philip


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: ternary operator sintax help

2009-10-06 Thread Tom Worster
just as ashley said it.


On 10/6/09 3:26 PM, "MEM"  wrote:

> Sorry all,
> It's ok. The sintax:
> 
>  class="mensagemErro">'.$erros['anexo'].'' :''); ?>
> 
> Was right all the time.
> 
> Anyway, I've learn something new: having a var with '' is not the same thing
> as not been unset. So we must pay attention on what cases we use isset, or
> !empty.
> 
> 
> Thanks a lot,
> Márcio
> 
>> -Original Message-
>> From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br]
>> Sent: terça-feira, 6 de Outubro de 2009 19:53
>> To: php-general@lists.php.net
>> Subject: [PHP] Re: ternary operator sintax help
>> 
>> > class="mensagemErro">'.$erros['anexo'].'' :''); ?>
>> 
>> ""MEM""  escreveu na mensagem
>> news:002401ca46b4$ed6ad6a0$c84083...@com...
>> Hello all,
>> 
>> I'm trying to display a div, only when some php value is set.
>> Since this will be near html, I'd like to keep it on one line. So, I'd
>> love
>> to use shortcuts and a ternary operator for the effect.
>> 
>> I'm having something like this right now, but the div still appears
>> even if
>> the error is NOT set.
>> 
>> '
>> .$erros['anexo'].'' :''; ?>
>> 
>> :(
>> 
>> Can I have your help with the right syntax ?
>> 
>> 
>> Regards,
>> The newbie on a Humpty Dumpty wall,
>> Márcio
>> 
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: ternary operator sintax help

2009-10-06 Thread MEM
Absolutely. ;) I was reporting to ashley teachings. :-)

Philip, thanks for the tip.

:-)
Thank you all,
Márcio

> -Original Message-
> From: Tom Worster [mailto:f...@thefsb.org]
> Sent: terça-feira, 6 de Outubro de 2009 21:10
> To: MEM; php-general@lists.php.net
> Subject: Re: [PHP] Re: ternary operator sintax help
> 
> just as ashley said it.
> 
> 
> On 10/6/09 3:26 PM, "MEM"  wrote:
> 
> > Sorry all,
> > It's ok. The sintax:
> >
> >  > class="mensagemErro">'.$erros['anexo'].'' :''); ?>
> >
> > Was right all the time.
> >
> > Anyway, I've learn something new: having a var with '' is not the
> same thing
> > as not been unset. So we must pay attention on what cases we use
> isset, or
> > !empty.
> >
> >
> > Thanks a lot,
> > Márcio
> >
> >> -Original Message-
> >> From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br]
> >> Sent: terça-feira, 6 de Outubro de 2009 19:53
> >> To: php-general@lists.php.net
> >> Subject: [PHP] Re: ternary operator sintax help
> >>
> >>  >> class="mensagemErro">'.$erros['anexo'].'' :''); ?>
> >>
> >> ""MEM""  escreveu na mensagem
> >> news:002401ca46b4$ed6ad6a0$c84083...@com...
> >> Hello all,
> >>
> >> I'm trying to display a div, only when some php value is set.
> >> Since this will be near html, I'd like to keep it on one line. So,
> I'd
> >> love
> >> to use shortcuts and a ternary operator for the effect.
> >>
> >> I'm having something like this right now, but the div still appears
> >> even if
> >> the error is NOT set.
> >>
> >> '
> >> .$erros['anexo'].'' :''; ?>
> >>
> >> :(
> >>
> >> Can I have your help with the right syntax ?
> >>
> >>
> >> Regards,
> >> The newbie on a Humpty Dumpty wall,
> >> Márcio
> >>
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [Fwd: [PHP] Sessions in databases]

2009-10-06 Thread Kim Madsen

Sam Stelfox wrote on 2009-10-06 18:09:
If you are distributing your application over multiple servers, using a 
database for session tracking allows a user to continue there session 
regardless of which server their request bounces too. It prevents the 
need for 'sticky' network connections which time out anyways. 


I know Alfio don't have access to the php.ini file, but if you do and 
have the above setup, consider using a tmp dir like /phptmp and have one 
root server and mount the other servers /phptmp to the root servers /phptmp


Kind regards
Kim Emax


Il pinguino volante wrote:

(There were some erroros in the previous email, I'm sorry)

Hi to all.

I have to realize an authentication system for a lot of users.

I heard that someone uses to store session states (?) into a database. 
I'd like to know how and, expecially, WHY to do it and what's would be 
better (considering that I CANNOT -d'oh!- edit the php.ini file).


Thanks in advance,
Alfio.








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi



> Furthermore, the amount
> of time micro-optimization takes up (going through old code, I mean)
> could be better spent doing something that actually does increase your
> performance, like implementing a search engine or memcached.  Going
> forward, if you're aware that ++i and i++ are the same for your
> application and ++i is a single php opcode faster (which I don't know
> if it's even measurable, that difference), sure go ahead and use ++i
> but it's certainly not worth serious thought or developer time.
> 
> My two cents.

I do micro optimization with every language I use, when I know, and where I 
can. I am the one that usually solves slow query problems, and I use best 
practices on database as well.

Guys, I don't get your point ... if you know that "$var" is a non-sense, feel 
free to use it ... what I know, is that every double quoted string require 
parsing, due to variable or char evaluations (\x00) evaluation, if I don't need 
this waste of time, why should I write a totally meaningless, useless, "$var" 
where $var is sufficient or more over 'whatever'.$var will be faster?

The fact is that this is my approach for every layer of an application, I am 
not like that only with PHP. There is something to optimize? Make it your code 
style and you won't spend a sinlge second more than any other, but at least 
you'll do your best to reach best performances.

As I have said, I have never had performances problem, and I am a full web 
stack developer, but you can obviously do whatever you want, is still a matter 
of points of view.

Regards




  
_
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi

ah ah ah  that's for sure, I've never said that is correct, I said that is 
illogical ;-)

> Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo
> Date: Tue, 6 Oct 2009 12:46:36 -0500
> From: jblanch...@pocket.com
> To: an_...@hotmail.com; tedd.sperl...@gmail.com; php-general@lists.php.net
> 
> [snip]
> ...micro optimizations...
> [/snip]
> 
> And in the land of micro optimization you would likely never see the
> following;
> 
> $a = $a++;
  
_
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi


> Eddie:
> 
> And thanks for supporting my point.

so you think as well that 3 characters, written like this i++, in a careless 
way, or like this ++i, make the difference about time spent to develop ... 
interesting

Regards
  
_
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi



> Speaking of starting a conversation, what do you think about the "goto"
> construct introduced just recently?

if used properly, could avoid recursion, and speed up operations ... there is 
nothing wrong with goto, everything we write on lowest level is a jump in the 
memory (as goto is a jump in the code flow)

++goto ... and not goto++

Regards
  
_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi



> if used properly, could avoid recursion, and speed up operations ... there is 
> nothing wrong with goto, everything we write on lowest level is a jump in the 
> memory (as goto is a jump in the code flow)
> 
> ++goto ... and not goto++

I forgot, I have always used goto in Batch script, which indeed can emulates 
functions, except there is no recursion problem. I have a couple of batches 
online if interesting, and from performances point of view, ask yourself why on 
earth PHP core developers have introduced goto and actually somebody is using 
it ;-)

Uh, I forgot I live in microoptimization land ... lol
  
_
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread clancy_1
On Tue, 6 Oct 2009 14:08:14 -0400, tedd.sperl...@gmail.com (tedd) wrote:

>At 10:48 AM -0300 10/6/09, Martin Scotta wrote:
>>No matter how silly it can looks like (a = a++) it is still completely valid
>>code and it SHOULD run without problems.
>
>Yeah, it's a valid as:
>
>$a = $a;
>
>and does the same thing, which is nothing.

No; it's worse, because it can be interpreted in two different ways, which is 
demonstrated
by the fact that it gives different results in different languages.

>If you want a statement that does something, then use:
>
>   $a = ++$a;
>
>or simply:
>
>   $a++;
>
>or
>
>   ++$a;
>
>Any of those will increment $a, whereas ($a = $a++;) does nothing.

According to Schlossnagel "Advanced PHP programming" it is better to use ++$a, 
because
this simply increments the variable, whereas $a++ makes a copy, and then 
increments the
variable, so it involves additional time and memory usage. I cannot see that it 
would ever
make a difference in the real world, but this is one of the tricks Schlossnagel 
advises
you should use when you want the fastest possible code.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd

At 1:09 AM +0200 10/7/09, Andrea Giammarchi wrote:

 > Eddie:


 And thanks for supporting my point.


so you think as well that 3 characters, written like this i++, in a 
careless way, or like this ++i, make the difference about time spent 
to develop ... interesting


No, just the opposite. It doesn't make any difference either way.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd

At 10:20 AM +1100 10/7/09, clanc...@cybec.com.au wrote:

On Tue, 6 Oct 2009 14:08:14 -0400, tedd.sperl...@gmail.com (tedd) wrote:


At 10:48 AM -0300 10/6/09, Martin Scotta wrote:

No matter how silly it can looks like (a = a++) it is still completely valid
code and it SHOULD run without problems.


Yeah, it's a valid as:

$a = $a;

and does the same thing, which is nothing.


No; it's worse, because it can be interpreted in two different ways, 
which is demonstrated

by the fact that it gives different results in different languages.



That's true for different languages, but I was talking about php. In 
some languages even the variable $a wouldn't be legal.


However, you are correct that the confusion such assignments would 
raise would create problems as well.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Daevid Vincent
 

> -Original Message-
> From: Paul M Foster [mailto:pa...@quillandmouse.com] 
> Sent: Tuesday, October 06, 2009 6:28 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Whacky increment/assignment logic with 
> $foo++ vs ++$foo
> 
> On Tue, Oct 06, 2009 at 08:51:17AM -0400, Bob McConnell wrote:
> 
> > From: Joost [mailto:joost.t.h...@planet.nl] 
> > > "Daevid Vincent" wrote:
> > >>> From: Ben Dunlap [mailto:bdun...@agentintellect.com]
> > 
> > >   $a = $a++;
> > 
> > I just think this is an ambiguous line of code that wasn't thought
> > through. The presence of the postfix operator makes the result
> > undefined, no matter what language you are using. It will 
> be an accident
> > if you get the results you are expecting.
> 
> The behavior of the ++ operator is the invention of Kernighan 
> and Ritchie.
> I don't imagine they ever foresaw anyone doing something as silly as
> 
> a = a++;
> 
> except under the rarest of circumstances.
> 
> Paul

Except that:

$a = 123;
$b = $a++;
echo $b;  //gives 123, not 124

as you logically expect it to and common sense would dictate, regardless of
what K&R or anyone else says.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Daevid Vincent
HEY! Don't try to hijack my astonishingly long-running thread! Start your
own Jay. ;-} 

> -Original Message-
> From: Jay Blanchard [mailto:jblanch...@pocket.com] 
> Sent: Tuesday, October 06, 2009 11:34 AM
> To: Tommy Pham; php-general@lists.php.net
> Subject: RE: [PHP] Whacky increment/assignment logic with 
> $foo++ vs ++$foo
> 
> [snip]
> I find it interesting for a discussion to go on this long for 
> something
> as
> $a = $a++;
> [/snip]
> 
> You think that is interesting? Start a conversation about these 
> 
> {}
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Robert Cummings

Andrea Giammarchi wrote:




if used properly, could avoid recursion, and speed up operations ... there is 
nothing wrong with goto, everything we write on lowest level is a jump in the 
memory (as goto is a jump in the code flow)

++goto ... and not goto++


I forgot, I have always used goto in Batch script, which indeed can emulates 
functions, except there is no recursion problem. I have a couple of batches 
online if interesting, and from performances point of view, ask yourself why on 
earth PHP core developers have introduced goto and actually somebody is using 
it ;-)

Uh, I forgot I live in microoptimization land ... lol


If you read the archives for PHP Internals you can view the discussion 
that went into the final decision to include GOTO. It happened 2 or 3 
years ago and I was certainly on the side arguing in its favour. The 
GOTO used in languages such as C and now PHP, is not the bastard GOTO of 
BASIC yesteryear. There are certainly use cases where the use of GOTO 
makes far more sense than other constructs. Finite state machines (often 
used in parsing) are one such place. In fact if you grep for goto on any 
major open source project's C code, you will probably find multiple 
occurrences. PHP, MySQL, and Apache all use goto.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php