Re: [PHP] Javascript question

2009-03-02 Thread Robert Cummings
On Mon, 2009-03-02 at 16:11 -0600, Boyd, Todd M. wrote:
 Before some of you newbies feel like being heroes and jump all over me:
 
 I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION, DON'T
 ANSWER IT.
 
 Now that that's out of the way... I have a Javascript question (and
 maybe a Browser/DOM question) for you folks. I'm not sure this is
 anything they teach you in any online/in-seat/self-taught Javascript
 course that I've ever seen before, so I figured I would bring it here.
 
 My boss asked me if I knew of a tool that would change the !DOCTYPE of
 a page on-the-fly to test validation in different schemes (i.e., XHTML
 Strict, Transitional, Loose, etc.). After a bit of looking around, this
 is the solution I came up with (as a bookmarklet):
 
 javascript:document.write('!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;' +
 document.getElementsByTagName('html')[0].innerHTML);
 
 However, I'm not sure it will fire any validation events, since
 technically the page has already been loaded (Javascript is just adding
 more text). I fear the case will be the same if the current page's
 source is sent to a new browser window.
 
 I'm not asking for any coding suggestions, necessarily--just curious as
 to whether or not anyone knew if this will invoke browser validation
 events or not. Comments and questions are more than welcome, though. :)

Can't you do it via PHP using a GET parameter? Seems more likely to work
properly since it requires the page be reloaded on a fresh slate. While
at the same time, it will easily jump through the doctypes that the
server deems suitable given the parameter

http://www.www.www/foo.php?doctype=xmlstrict1.0

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



RE: [PHP] Javascript question

2009-03-02 Thread Boyd, Todd M.
 -Original Message-
 From: Robert Cummings [mailto:rob...@interjinn.com]
 Sent: Monday, March 02, 2009 4:18 PM
 To: Boyd, Todd M.
 Cc: PHP General list
 Subject: Re: [PHP] Javascript question
 
 On Mon, 2009-03-02 at 16:11 -0600, Boyd, Todd M. wrote:
  Before some of you newbies feel like being heroes and jump all over
 me:
 
  I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION,
 DON'T
  ANSWER IT.
 
  Now that that's out of the way... I have a Javascript question (and
  maybe a Browser/DOM question) for you folks. I'm not sure this is
  anything they teach you in any online/in-seat/self-taught Javascript
  course that I've ever seen before, so I figured I would bring it
 here.
 
  My boss asked me if I knew of a tool that would change the
!DOCTYPE
 of
  a page on-the-fly to test validation in different schemes (i.e.,
 XHTML
  Strict, Transitional, Loose, etc.). After a bit of looking around,
 this
  is the solution I came up with (as a bookmarklet):
 
  javascript:document.write('!DOCTYPE html PUBLIC -//W3C//DTD XHTML
 1.0
  Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;' +
  document.getElementsByTagName('html')[0].innerHTML);
 
  However, I'm not sure it will fire any validation events, since
  technically the page has already been loaded (Javascript is just
 adding
  more text). I fear the case will be the same if the current page's
  source is sent to a new browser window.
 
  I'm not asking for any coding suggestions, necessarily--just curious
 as
  to whether or not anyone knew if this will invoke browser validation
  events or not. Comments and questions are more than welcome, though.
 :)
 
 Can't you do it via PHP using a GET parameter? Seems more likely to
 work
 properly since it requires the page be reloaded on a fresh slate.
While
 at the same time, it will easily jump through the doctypes that the
 server deems suitable given the parameter
 
 http://www.www.www/foo.php?doctype=xmlstrict1.0

Rob,

Absolutely. However, requiring a server-side script was something I was
hoping to avoid. It may be useful as an intranet utility somewhere down
the road, but a bookmarklet was what I was shooting for for this first
test.

Great minds think alike, eh? :)


// Todd

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



RE: [PHP] Javascript question

2009-03-02 Thread Boyd, Todd M.
 -Original Message-
 From: Michael A. Peters [mailto:mpet...@mac.com]
 Sent: Monday, March 02, 2009 4:42 PM
 To: Boyd, Todd M.
 Cc: PHP General list
 Subject: Re: [PHP] Javascript question
 
 Boyd, Todd M. wrote:
  Before some of you newbies feel like being heroes and jump all over
 me:
 
  I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION,
 DON'T
  ANSWER IT.
 
  Now that that's out of the way... I have a Javascript question (and
  maybe a Browser/DOM question) for you folks. I'm not sure this is
  anything they teach you in any online/in-seat/self-taught Javascript
  course that I've ever seen before, so I figured I would bring it
 here.
 
  My boss asked me if I knew of a tool that would change the
!DOCTYPE
 of
  a page on-the-fly to test validation in different schemes (i.e.,
 XHTML
  Strict, Transitional, Loose, etc.).
 
 The validators generally don't trigger javascript.
 
 I use DOMDocument to create a valid xhtml page and then before sending
 it to the browser - if the browser does not report accepting valid
 xhtml
 (or I specify I want html) it filters the page to valid html 4.01.
 
 That's probably what you want to do - code for valid xhtml and filter
 the output to other DTD's you want to make available server side
rather
 than trying to use JS to alter the DOCTYPE.
 
 Remember, the proper header to send also relies on the DOCTYPE so if
 you
 sent a header for xhtml but send html (or vice versa) you are still
 breaking the standard regardless of how pristine your output is.
 
 Another advantage to building the document ahead of time and doing any
 translations server side is you can also filter the output for XSS in
 case you missed validating some input.

I think you guys are missing the point--this is not for proprietary use
on our own server with our own pages. I wanted to write a bookmarklet
that would work for any page, on any server. I'm beginning to think
that's not necessarily possible (using just JS and the browser).

Thanks for all of your suggestions, anyway. :)


// Todd

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



Re: [PHP] Javascript question

2009-03-02 Thread Michael A. Peters

Boyd, Todd M. wrote:

Before some of you newbies feel like being heroes and jump all over me:

I KNOW THIS IS A PHP-RELATED LIST. IF YOU DON'T LIKE MY QUESTION, DON'T
ANSWER IT.

Now that that's out of the way... I have a Javascript question (and
maybe a Browser/DOM question) for you folks. I'm not sure this is
anything they teach you in any online/in-seat/self-taught Javascript
course that I've ever seen before, so I figured I would bring it here.

My boss asked me if I knew of a tool that would change the !DOCTYPE of
a page on-the-fly to test validation in different schemes (i.e., XHTML
Strict, Transitional, Loose, etc.).


The validators generally don't trigger javascript.

I use DOMDocument to create a valid xhtml page and then before sending 
it to the browser - if the browser does not report accepting valid xhtml 
(or I specify I want html) it filters the page to valid html 4.01.


That's probably what you want to do - code for valid xhtml and filter 
the output to other DTD's you want to make available server side rather 
than trying to use JS to alter the DOCTYPE.


Remember, the proper header to send also relies on the DOCTYPE so if you 
sent a header for xhtml but send html (or vice versa) you are still 
breaking the standard regardless of how pristine your output is.


Another advantage to building the document ahead of time and doing any 
translations server side is you can also filter the output for XSS in 
case you missed validating some input.


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



Re: [PHP] preg_match question...

2009-02-06 Thread Alpár Török
preg_match('/^([0-9]+) (.)+/',$sString,$aMatches);

Matches will be 1 = the number ; 2 = the text. The expression only matches
if there is any character after the space.  Not necessarily text, it might
be another number or special characters

2009/2/6 bruce bedoug...@earthlink.net

 hi...

 trying to figure out the best approach to using preg_match to extract the
 number from the follwing type of line...

  131646 sometext follows..

 basically, i want to extract the number, without the text, but i have to be
 able to match on the text

 i've been playing with different preg_match regexs.. but i'm missing
 something obvious!

 thoughts/comments..


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




-- 
Alpar Torok


Re: [PHP] preg_match question...

2009-02-06 Thread Jim Lucas
bruce wrote:
 hi...
 
 trying to figure out the best approach to using preg_match to extract the
 number from the follwing type of line...
 
  131646 sometext follows..
 
 basically, i want to extract the number, without the text, but i have to be
 able to match on the text
 
 i've been playing with different preg_match regexs.. but i'm missing
 something obvious!
 
 thoughts/comments..
 
 

Why don't you show us some of the attempts that you have tried that didn't work.

When you say that you need to match on some of the text, give us an example of 
the text that you are trying to match.

And give us examples of the input text you are trying to match to.

-- 
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] function_exists question

2009-02-05 Thread Thodoris


Is there a way to check not only if a function exists, but also to 
check that the number and types of parameters desired match a function 
definition?


The reason being that additional options have been added in php 4 and 
5 to various standard function calls, but I'm still running a php3 and 
php4 server in addition to a php5 server.  I would like to make sure 
that certain extended function calls still work in all versions (or 
I'll perform the tasks manually, albeit less efficiently).


One example I can think of is the round() function.  The $precision 
parameter was added in php4, so will not work in php3.  However, 
function_exists would return TRUE for both 3 and 4, but round itself 
would fail if I tried to send a precision level to the php3 server.


Thanks much,
Matt

P.S. Of course the modified function_exists would unfortunately have 
to be a recognized function/method in php3 in order for me to call it 
to check parameter counts on a php3 server :(




I am sure you have some good reasons for keeping php3 right?

Why don't you consider updating to at least php4 ??

PHPv3 is not even maintained and PHPv4 is not being developed any more.

So by the end of this year (I hope) we will start using a stable PHPv6.

IMHO you should consider changing your code (if this is possible) to a 
more mainstream version.


--
Thodoris


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



Re: [PHP] function_exists question

2009-02-05 Thread German Geek
Why can't you update to Version 5? I might be a bit anal about trying to
always get the newest version of everything, but seriously version 3 has
surely more known security issues as well as performance costs.

What's the cost of upgrading compared to the cost of writing code that works
in every version? I think upgrading the system to PHP 5 will take you maybe
half an hour, while you can spend a lot more hours on writing backward
compatible code. PHP is not very good with compatibility across versions
anyway. Hopefully all PHP 5 code will work in PHP 6.

How about this PHP developers: You could make a global variable (or
constant) the user can set like

define('PHP_COMPATIBLE_VERSION', '5.0.1');

or something to tell PHP 6 to interpret it like PHP 5.x . That way, at least
you are guaranteed that the code will work like on that version. It might
make PHP 6 (a lot?) bigger but it might be worth the cost, since all Sites
written in PHP will still work. The functions could still have a performance
boost that way if there are better algorithms.

Sorry for steeling the thread.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Feb 6, 2009 at 12:55 AM, Thodoris t...@kinetix.gr wrote:


  Is there a way to check not only if a function exists, but also to check
 that the number and types of parameters desired match a function definition?

 The reason being that additional options have been added in php 4 and 5 to
 various standard function calls, but I'm still running a php3 and php4
 server in addition to a php5 server.  I would like to make sure that certain
 extended function calls still work in all versions (or I'll perform the
 tasks manually, albeit less efficiently).

 One example I can think of is the round() function.  The $precision
 parameter was added in php4, so will not work in php3.  However,
 function_exists would return TRUE for both 3 and 4, but round itself would
 fail if I tried to send a precision level to the php3 server.

 Thanks much,
 Matt

 P.S. Of course the modified function_exists would unfortunately have to
 be a recognized function/method in php3 in order for me to call it to check
 parameter counts on a php3 server :(


 I am sure you have some good reasons for keeping php3 right?

 Why don't you consider updating to at least php4 ??

 PHPv3 is not even maintained and PHPv4 is not being developed any more.

 So by the end of this year (I hope) we will start using a stable PHPv6.

 IMHO you should consider changing your code (if this is possible) to a more
 mainstream version.

 --
 Thodoris



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




RE: [PHP] function_exists question

2009-02-05 Thread Boyd, Todd M.
 -Original Message-
 From: th.he...@gmail.com [mailto:th.he...@gmail.com] On Behalf Of
 German Geek
 Sent: Thursday, February 05, 2009 5:02 PM
 To: t...@kinetix.gr
 Cc: Matt Pagel; php-general@lists.php.net
 Subject: Re: [PHP] function_exists question
 
 Why can't you update to Version 5? I might be a bit anal about trying
 to
 always get the newest version of everything, but seriously version 3
 has
 surely more known security issues as well as performance costs.
 
 What's the cost of upgrading compared to the cost of writing code that
 works
 in every version? I think upgrading the system to PHP 5 will take you
 maybe
 half an hour, while you can spend a lot more hours on writing backward
 compatible code. PHP is not very good with compatibility across
 versions
 anyway. Hopefully all PHP 5 code will work in PHP 6.
 
 How about this PHP developers: You could make a global variable (or
 constant) the user can set like
 
 define('PHP_COMPATIBLE_VERSION', '5.0.1');
 
 or something to tell PHP 6 to interpret it like PHP 5.x . That way, at
 least
 you are guaranteed that the code will work like on that version. It
 might
 make PHP 6 (a lot?) bigger but it might be worth the cost, since all
 Sites
 written in PHP will still work. The functions could still have a
 performance
 boost that way if there are better algorithms.
 
 Sorry for steeling the thread.
 
 Regards,
 Tim
 
 Tim-Hinnerk Heuer
 
 http://www.ihostnz.com
 
 
 On Fri, Feb 6, 2009 at 12:55 AM, Thodoris t...@kinetix.gr wrote:
 
 
   Is there a way to check not only if a function exists, but also to
 check
  that the number and types of parameters desired match a function
 definition?
 
  The reason being that additional options have been added in php 4
 and 5 to
  various standard function calls, but I'm still running a php3 and
 php4
  server in addition to a php5 server.  I would like to make sure
that
 certain
  extended function calls still work in all versions (or I'll
 perform the
  tasks manually, albeit less efficiently).
 
  One example I can think of is the round() function.  The $precision
  parameter was added in php4, so will not work in php3.  However,
  function_exists would return TRUE for both 3 and 4, but round
itself
 would
  fail if I tried to send a precision level to the php3 server.
 
  Thanks much,
  Matt
 
  P.S. Of course the modified function_exists would unfortunately
 have to
  be a recognized function/method in php3 in order for me to call it
 to check
  parameter counts on a php3 server :(
 
 
  I am sure you have some good reasons for keeping php3 right?
 
  Why don't you consider updating to at least php4 ??
 
  PHPv3 is not even maintained and PHPv4 is not being developed any
 more.
 
  So by the end of this year (I hope) we will start using a stable
 PHPv6.
 
  IMHO you should consider changing your code (if this is possible) to
 a more
  mainstream version.

I think it would be much easier to run several versions of PHP in tandem
on the same server, and let an .htaccess file (or some other such
convention) determine the version of PHP to run particular
files/directories/etc. with.

My 2c,


// Todd

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



Re: [PHP] function_exists question

2009-02-05 Thread Chris



How about this PHP developers: You could make a global variable (or
constant) the user can set like

define('PHP_COMPATIBLE_VERSION', '5.0.1');

or something to tell PHP 6 to interpret it like PHP 5.x . That way, at least
you are guaranteed that the code will work like on that version. It might
make PHP 6 (a lot?) bigger but it might be worth the cost, since all Sites
written in PHP will still work. The functions could still have a performance
boost that way if there are better algorithms.


php5 introduced this:

http://au.php.net/manual/en/ini.core.php#ini.zend.ze1-compatibility-mode

to make sure php5 interpreted php4 code in a b/c way, they may do 
something similar for php6 - php5.


Doing it at runtime is silly imo.

--
Postgresql  php tutorials
http://www.designmagick.com/


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



RE: [PHP] Payment question in Canada

2009-01-31 Thread Ernie Kemp
Thanks for your replies.

Very useful...
/Ernie


-Original Message-
From: farn...@googlemail.com [mailto:farn...@googlemail.com] On Behalf Of 
Edmund Hertle
Sent: January-30-09 4:47 PM
To: Bastien Koert
Cc: Ernie Kemp; php-general@lists.php.net
Subject: Re: [PHP] Payment question in Canada

2009/1/30 Bastien Koert phps...@gmail.com

 On Fri, Jan 30, 2009 at 2:11 PM, Ernie Kemp ernie.k...@sympatico.ca
 wrote:

My question is one of pay; hope this is the correct forum.
 
 
 
  A couple of people have asked me to write some PHP code for their website
  backend.
 
 
 
  I need the money from this but I don't know what to charge them.  I think
  in total the work will be about 8-10 hours.
 
 
 
  Please indicate what hourly fee I should charge them as don't wish to
  overcharge them nor under value my services.
 
 
 
  If I have the wrong list, let me know which list to go to.
 
 
 
  Thanks in advance,
 
 
 
 
 
  Thanks,
 
  Ernie
 
 
 
 
 
  ...man will occasionally stumble over the truth, but usually manages to
  pick himself up, walk over or around it, and carry on.
 
 
Winston S. Churchill* *
 
 
 
 
 
 
 
 
 
 I charge anywhere from $50-$75/hr depending on the project and exactly what
 the client wants


 --

 Bastien


Read this discussion. I think this will help you:
http://marc.info/?t=12329898971r=1w=2

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.0.233 / Virus Database: 270.10.16/1925 - Release Date: 01/30/09 
07:37:00


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



Re: [PHP] Payment question in Canada

2009-01-31 Thread Daniel Brown
On Sat, Jan 31, 2009 at 13:44, Ernie Kemp ernie.k...@sympatico.ca wrote:
 Thanks for your replies.

 Very useful...
 /Ernie

Please don't top-post.

This question doesn't have a direct answer.  Three major things
come into play: first, the type and scope of work involved; second,
your level of skill and what it's worth; and finally, the perceived
value of the cost-vs-service by the client.  If they think they're
getting a fair (or even great) deal, then the price is fine.

The big thing that throws up a red flag is that you're asking
about what to bill a client for the work - if you're unsure of what to
charge for something like this, it says that you're not used to
performing at a professional level yet.  This isn't anything at all
against you personally, it's a mistake that nearly everyone makes when
they're first getting their feet wet in freelance services.  I'd
recommend reading through some forums and mailing list archives -
especially discussions between service buyers - to see what's fair and
going rate for your skill level and years of experience.

Best of luck with everything, Ernie.


P.S. - This is the General list, so you did ask in the right place.  ;-P

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Payment question in Canada

2009-01-30 Thread Bastien Koert
On Fri, Jan 30, 2009 at 2:11 PM, Ernie Kemp ernie.k...@sympatico.ca wrote:

   My question is one of pay; hope this is the correct forum.



 A couple of people have asked me to write some PHP code for their website
 backend.



 I need the money from this but I don't know what to charge them.  I think
 in total the work will be about 8-10 hours.



 Please indicate what hourly fee I should charge them as don't wish to
 overcharge them nor under value my services.



 If I have the wrong list, let me know which list to go to.



 Thanks in advance,





 Thanks,

 Ernie





 ...man will occasionally stumble over the truth, but usually manages to
 pick himself up, walk over or around it, and carry on.


   Winston S. Churchill* *









I charge anywhere from $50-$75/hr depending on the project and exactly what
the client wants


-- 

Bastien

Cat, the other other white meat


Re: [PHP] Payment question in Canada

2009-01-30 Thread Edmund Hertle
2009/1/30 Bastien Koert phps...@gmail.com

 On Fri, Jan 30, 2009 at 2:11 PM, Ernie Kemp ernie.k...@sympatico.ca
 wrote:

My question is one of pay; hope this is the correct forum.
 
 
 
  A couple of people have asked me to write some PHP code for their website
  backend.
 
 
 
  I need the money from this but I don't know what to charge them.  I think
  in total the work will be about 8-10 hours.
 
 
 
  Please indicate what hourly fee I should charge them as don't wish to
  overcharge them nor under value my services.
 
 
 
  If I have the wrong list, let me know which list to go to.
 
 
 
  Thanks in advance,
 
 
 
 
 
  Thanks,
 
  Ernie
 
 
 
 
 
  ...man will occasionally stumble over the truth, but usually manages to
  pick himself up, walk over or around it, and carry on.
 
 
Winston S. Churchill* *
 
 
 
 
 
 
 
 
 
 I charge anywhere from $50-$75/hr depending on the project and exactly what
 the client wants


 --

 Bastien


Read this discussion. I think this will help you:
http://marc.info/?t=12329898971r=1w=2


Re: [PHP] Cookie Question

2009-01-17 Thread Török Alpár
2009/1/17 PHP php_l...@ibcnetwork.net

 Hi,
 I am trying to get a cookie to set in Internet Explorer 7, I have tried
 several different setcookie() configurations, this is the latest.
 Yes, I read the manual and the user notes, but can't find anything specific
 about the different security levels in IE.

 $szCookieName = MyCookie;
 $nID = 2;
 $expireTime = 60*60;

 setcookie($szCookieName, $nID, time()-$expireTime,/,www.mysite.com
 ,false);


   is there any reason that you set the expire in the past? That is usually
used to delete a cookie, not set it. I had many problems with IE in general,
but cookies were never a problem.




 However, they all work, only if I have the Privacy slider set to low in
 IE's options.
 As soon as I go up to medium, it will not work.

 And it works fine with firefox.

 The only difference I can see is that Medium Security adds the rule:

 Restricts first-party cookies that save information that can be used to
 contact you without your implicit consent.

 All I am storing is an integer value, why is IE seeing that as information
 that can contact you?

 Thanks for any help.

 Chris




-- 
Torok, Alpar Istvan


Re: [PHP] Cookie Question

2009-01-17 Thread PHP

Oops, copy and paste error, that is the cookie I was using to delete.

The one I am using to set is acutally:
setcookie($szCookieName, $nID, 
time()+$expireTime,/,www.mysite.com,false);





2009/1/17 PHP php_l...@ibcnetwork.net


Hi,
I am trying to get a cookie to set in Internet Explorer 7, I have tried
several different setcookie() configurations, this is the latest.
Yes, I read the manual and the user notes, but can't find anything 
specific

about the different security levels in IE.

$szCookieName = MyCookie;
$nID = 2;
$expireTime = 60*60;

setcookie($szCookieName, $nID, time()-$expireTime,/,www.mysite.com
,false);



  is there any reason that you set the expire in the past? That is usually
used to delete a cookie, not set it. I had many problems with IE in 
general,

but cookies were never a problem.





However, they all work, only if I have the Privacy slider set to low in
IE's options.
As soon as I go up to medium, it will not work.

And it works fine with firefox.

The only difference I can see is that Medium Security adds the rule:

Restricts first-party cookies that save information that can be used to
contact you without your implicit consent.

All I am storing is an integer value, why is IE seeing that as 
information

that can contact you?

Thanks for any help.

Chris





--
Torok, Alpar Istvan






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



Re: [PHP] preg_match_all question

2009-01-16 Thread Robert Cummings
On Fri, 2009-01-16 at 09:42 +, Phil Ewington - iModel Ltd. wrote:
 Hi All,
 
 Having an issue with regular expressions, never been my strong point!
 
 The following pattern only picks up one instance per line, if more than 
 one instance exists all text from first {{ to last }} is included, can 
 anyone point out where I am going wrong?
 
 preg_match_all(/\{\{lang:(.*)\}\}/, $str, $tags);

You need the ungreedy modifier:

preg_match_all(/\{\{lang:(.*)\}\}/U, $str, $tags);

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



Re: [PHP] preg_match_all question

2009-01-16 Thread Phil Ewington - iModel Ltd.

Robert Cummings wrote:

On Fri, 2009-01-16 at 09:42 +, Phil Ewington - iModel Ltd. wrote:
  

Hi All,

Having an issue with regular expressions, never been my strong point!

The following pattern only picks up one instance per line, if more than 
one instance exists all text from first {{ to last }} is included, can 
anyone point out where I am going wrong?


preg_match_all(/\{\{lang:(.*)\}\}/, $str, $tags);



You need the ungreedy modifier:

preg_match_all(/\{\{lang:(.*)\}\}/U, $str, $tags);

Cheers,
Rob.
  

Rob you're a star, thanks mate.

- Phil

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



RE: [PHP] preg_match_all question

2009-01-16 Thread Boyd, Todd M.
 -Original Message-
 From: Robert Cummings [mailto:rob...@interjinn.com]
 Sent: Friday, January 16, 2009 4:31 AM
 To: Phil Ewington - iModel Ltd.
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] preg_match_all question
 
 On Fri, 2009-01-16 at 09:42 +, Phil Ewington - iModel Ltd. wrote:
  Hi All,
 
  Having an issue with regular expressions, never been my strong
point!
 
  The following pattern only picks up one instance per line, if more
 than
  one instance exists all text from first {{ to last }} is included,
 can
  anyone point out where I am going wrong?
 
  preg_match_all(/\{\{lang:(.*)\}\}/, $str, $tags);
 
 You need the ungreedy modifier:
 
 preg_match_all(/\{\{lang:(.*)\}\}/U, $str, $tags);

FWIW, you can tell just the .* to be un-greedy using a ? like so:

preg_match_all('/\{\{lang:(.*?)\|\|/', $str, $tags);


// Todd

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



RE: [PHP] preg_match_all question

2009-01-16 Thread Boyd, Todd M.
 -Original Message-
 From: Boyd, Todd M. [mailto:tmbo...@ccis.edu]
 Sent: Friday, January 16, 2009 2:13 PM
 To: php-general@lists.php.net
 Subject: RE: [PHP] preg_match_all question
 
  -Original Message-
  From: Robert Cummings [mailto:rob...@interjinn.com]
  Sent: Friday, January 16, 2009 4:31 AM
  To: Phil Ewington - iModel Ltd.
  Cc: php-general@lists.php.net
  Subject: Re: [PHP] preg_match_all question
 
  On Fri, 2009-01-16 at 09:42 +, Phil Ewington - iModel Ltd.
wrote:
   Hi All,
  
   Having an issue with regular expressions, never been my strong
 point!
  
   The following pattern only picks up one instance per line, if more
  than
   one instance exists all text from first {{ to last }} is included,
  can
   anyone point out where I am going wrong?
  
   preg_match_all(/\{\{lang:(.*)\}\}/, $str, $tags);
 
  You need the ungreedy modifier:
 
  preg_match_all(/\{\{lang:(.*)\}\}/U, $str, $tags);
 
 FWIW, you can tell just the .* to be un-greedy using a ? like so:
 
 preg_match_all('/\{\{lang:(.*?)\|\|/', $str, $tags);

Correction:

preg_match_all('/\{\{lang:(.*?)\}\}/', $str, $tags);

...turned my squiggly brackets into pipe chars in a fit of randomness.


// Todd

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



Re: [PHP] Security question

2009-01-15 Thread Frank Stanovcak

VamVan vamsee...@gmail.com wrote in message 
news:12eb8b030901141421u6741b943q396bc784136b7...@mail.gmail.com...
 On Wed, Jan 14, 2009 at 2:22 PM, Frank Stanovcak
 blindspot...@comcast.netwrote:

 This is mostly to make sure I understand how sessions are handled
 correctly.
 As far as sessions are concerned the variable data is stored on the 
 server
 (be it in memory or temp files), and never transmitted accross the net
 unless output to the page?  So this means I should be able to store the
 username and password for a program in session vars for quick 
 validations,
 and if I force rentry of the password for sensitive areas (every time) 
 even
 if someone mannages to spoof the sesid all they will have access to is 
 non
 sensitive areas?  This also assumes I, at least, quick validate at the
 start
 of every page immideately after starting the session.



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


 Password should never be stored anywhere in clear text. You can store md5
 version in session or database. As long as password is encrypted ure fine
 and safe.

 Thanks,
 V


Thanks V
So if I store the hash in the db, and in the session var then I should be 
resonably safe provided I salt the hash prior to storing it? 



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



Re: [PHP] Security question

2009-01-15 Thread Micah Gersten
Frank Stanovcak wrote:
 VamVan vamsee...@gmail.com wrote in message 
 news:12eb8b030901141421u6741b943q396bc784136b7...@mail.gmail.com...
   
 On Wed, Jan 14, 2009 at 2:22 PM, Frank Stanovcak
 blindspot...@comcast.netwrote:

 
 This is mostly to make sure I understand how sessions are handled
 correctly.
 As far as sessions are concerned the variable data is stored on the 
 server
 (be it in memory or temp files), and never transmitted accross the net
 unless output to the page?  So this means I should be able to store the
 username and password for a program in session vars for quick 
 validations,
 and if I force rentry of the password for sensitive areas (every time) 
 even
 if someone mannages to spoof the sesid all they will have access to is 
 non
 sensitive areas?  This also assumes I, at least, quick validate at the
 start
 of every page immideately after starting the session.



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


   
 Password should never be stored anywhere in clear text. You can store md5
 version in session or database. As long as password is encrypted ure fine
 and safe.

 Thanks,
 V

 

 Thanks V
 So if I store the hash in the db, and in the session var then I should be 
 resonably safe provided I salt the hash prior to storing it? 



   
Yes, but don't use md5.  There are lookups available to help someone
crack it.   Try sha1:
http://us3.php.net/sha1

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




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



Re: [PHP] Security question

2009-01-14 Thread VamVan
On Wed, Jan 14, 2009 at 2:22 PM, Frank Stanovcak
blindspot...@comcast.netwrote:

 This is mostly to make sure I understand how sessions are handled
 correctly.
 As far as sessions are concerned the variable data is stored on the server
 (be it in memory or temp files), and never transmitted accross the net
 unless output to the page?  So this means I should be able to store the
 username and password for a program in session vars for quick validations,
 and if I force rentry of the password for sensitive areas (every time) even
 if someone mannages to spoof the sesid all they will have access to is non
 sensitive areas?  This also assumes I, at least, quick validate at the
 start
 of every page immideately after starting the session.



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


Password should never be stored anywhere in clear text. You can store md5
version in session or database. As long as password is encrypted ure fine
and safe.

Thanks,
V


Re: [PHP] system() Question

2009-01-01 Thread Nathan Nobbe
On Thu, Jan 1, 2009 at 12:01 AM, Daniel Brown danbr...@php.net wrote:

 On Thu, Jan 1, 2009 at 01:57, Jim Lucas li...@cmsws.com wrote:
 
  Getting in some practice for new little one?  :)

 Damn kids ;-P

  Happy New Year to all, and to all a safe night!

 To you as well, Mr. Lucas!  And now that I am done with work (for
 the most part), this is my official adieu to 2008.  Thanks for the
 memories.


merry new year to all you folks out there, wherever you hail from!

-nathan


Re: [PHP] Quick question regarding debugging and PHP structure.

2009-01-01 Thread Nathan Rixham

Ashley Sheridan wrote:

On Wed, 2008-12-31 at 20:41 +, Ólafur Waage wrote:

Short: Is it possible to see the PHP code that is going to be
processed in whole?

Long: I love to see things visually, and while programming i create
all kinds of debugging variables i keep on the side for each
page/request.
I know this is possibly not possible since this has to be done from
either the Zend Engine or PHP itself, but if i could see a complete
output of all the code within my project that is used for a certain
execution.

Example:
I call index.php?page=10

index.php includes functions.php and classes.php
classes.php include page_classes.php if there is a $_GET[page]
variable set and product_classes.php if there is a $_GET[product]
variable set

What i would like to see is the linear output of what code is included
(so the data of functions.php, classes.php, then page_classes.php, and
then index.php (not product_classes.php since its not included within
this request)

This is most likely possible with some PHP code but I'm thinking of
trying to make sense of an old project i didn't create quickly and if
this is possible it would help a lot.


Have you looked at PHPDebug? It offers something similar to what has
been offered by ASP, ColdFusion, and .Net in terms of debugging output,
and could help you?


Ash
www.ashleysheridan.co.uk



you can also just use eclipse+pdt, stick it in debug mode and step 
through every line of code exploring all the variables and such like 
every step of the way


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



Re: [PHP] Quick question regarding debugging and PHP structure.

2008-12-31 Thread Ashley Sheridan
On Wed, 2008-12-31 at 20:41 +, Ólafur Waage wrote:
 Short: Is it possible to see the PHP code that is going to be
 processed in whole?
 
 Long: I love to see things visually, and while programming i create
 all kinds of debugging variables i keep on the side for each
 page/request.
 I know this is possibly not possible since this has to be done from
 either the Zend Engine or PHP itself, but if i could see a complete
 output of all the code within my project that is used for a certain
 execution.
 
 Example:
 I call index.php?page=10
 
 index.php includes functions.php and classes.php
 classes.php include page_classes.php if there is a $_GET[page]
 variable set and product_classes.php if there is a $_GET[product]
 variable set
 
 What i would like to see is the linear output of what code is included
 (so the data of functions.php, classes.php, then page_classes.php, and
 then index.php (not product_classes.php since its not included within
 this request)
 
 This is most likely possible with some PHP code but I'm thinking of
 trying to make sense of an old project i didn't create quickly and if
 this is possible it would help a lot.
 
Have you looked at PHPDebug? It offers something similar to what has
been offered by ASP, ColdFusion, and .Net in terms of debugging output,
and could help you?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] system() Question

2008-12-31 Thread Micah Gersten
Nathan Nobbe wrote:


 On Sun, Dec 28, 2008 at 8:40 PM, Micah Gersten mi...@onshore.com
 mailto:mi...@onshore.com wrote:

 Nathan Nobbe wrote:
  good point dan, and just to add further clarification, thats b/c the
  function specifies $return_var is passed by reference in the formal
  parameter.  when you include the  along w/ an actual parameter
 (during
  function invocation) thats referred to as
 call-time-pass-by-reference in
  php, and its typically frowned upon.  in fact, i think its being
 removed
  from a future version of php.
 
  -nathan
 
 
 You don't call system using the ampersand.  The reference is
 declared in
 the function definition.  There's no reason for this to be frowned
 upon.


 well i dont think they deprecated it for shits--giggles.

 http://us.php.net/manual/en/language.references.pass.php

 its disabled by default in php.ini; wonder why.. ;)
  

   What you are referring to is the old PHP4 style of explicit
 pass-by-reference in function usage which is frowned upon.


 no im referring to call-time-pass by reference, which works just as
 well in php5; as long as you enable it in php.ini (or one of the other
 various ways).

 and also, for clarification, marking parameters as pass-by-reference
 works during method definition in php4 as well, of course.

 -nathan

I think I was confused here about your response.  After re-reading a few
times, I see that you were enhancing Dan's response by explaining what
call-time pass by reference is, not saying that the function is used
that way.
My apologies.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



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



Re: [PHP] system() Question

2008-12-31 Thread Nathan Nobbe
On Wed, Dec 31, 2008 at 7:03 PM, Micah Gersten mi...@onshore.com wrote:

 Nathan Nobbe wrote:
 
 
  On Sun, Dec 28, 2008 at 8:40 PM, Micah Gersten mi...@onshore.com
  mailto:mi...@onshore.com wrote:
 
  Nathan Nobbe wrote:
   good point dan, and just to add further clarification, thats b/c
 the
   function specifies $return_var is passed by reference in the formal
   parameter.  when you include the  along w/ an actual parameter
  (during
   function invocation) thats referred to as
  call-time-pass-by-reference in
   php, and its typically frowned upon.  in fact, i think its being
  removed
   from a future version of php.
  
   -nathan
  
  
  You don't call system using the ampersand.  The reference is
  declared in
  the function definition.  There's no reason for this to be frowned
  upon.
 
 
  well i dont think they deprecated it for shits--giggles.
 
  http://us.php.net/manual/en/language.references.pass.php
 
  its disabled by default in php.ini; wonder why.. ;)
 
 
What you are referring to is the old PHP4 style of explicit
  pass-by-reference in function usage which is frowned upon.
 
 
  no im referring to call-time-pass by reference, which works just as
  well in php5; as long as you enable it in php.ini (or one of the other
  various ways).
 
  and also, for clarification, marking parameters as pass-by-reference
  works during method definition in php4 as well, of course.
 
  -nathan
 
 I think I was confused here about your response.  After re-reading a few
 times, I see that you were enhancing Dan's response by explaining what
 call-time pass by reference is, not saying that the function is used
 that way.
 My apologies.


no worries

-nathan


Re: [PHP] system() Question

2008-12-31 Thread Daniel Brown
On Wed, Dec 31, 2008 at 21:29, Nathan Nobbe quickshif...@gmail.com wrote:
 On Wed, Dec 31, 2008 at 7:03 PM, Micah Gersten mi...@onshore.com wrote:

 I think I was confused here about your response.  After re-reading a few
 times, I see that you were enhancing Dan's response by explaining what
 call-time pass by reference is, not saying that the function is used
 that way.
 My apologies.

 no worries

So help me God, if you two don't stop fighting, I'm going to turn
this car around


(;-P)

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] system() Question

2008-12-31 Thread Jim Lucas

Daniel Brown wrote:

On Wed, Dec 31, 2008 at 21:29, Nathan Nobbe quickshif...@gmail.com wrote:

On Wed, Dec 31, 2008 at 7:03 PM, Micah Gersten mi...@onshore.com wrote:

I think I was confused here about your response.  After re-reading a few
times, I see that you were enhancing Dan's response by explaining what
call-time pass by reference is, not saying that the function is used
that way.
My apologies.

no worries


So help me God, if you two don't stop fighting, I'm going to turn
this car around


(;-P)



Getting in some practice for new little one?  :)

Happy New Year to all, and to all a safe night!

--
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] system() Question

2008-12-31 Thread Daniel Brown
On Thu, Jan 1, 2009 at 01:57, Jim Lucas li...@cmsws.com wrote:

 Getting in some practice for new little one?  :)

Damn kids ;-P

 Happy New Year to all, and to all a safe night!

To you as well, Mr. Lucas!  And now that I am done with work (for
the most part), this is my official adieu to 2008.  Thanks for the
memories.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] mysql question

2008-12-29 Thread Phpster
The mysql forum is the best place. Note that their holiday schedule  
may mean some lag in getting answers.


Bastien

Sent from my iPod

On Dec 29, 2008, at 7:51 AM, ann kok oiyan...@yahoo.ca wrote:


Hi all

Do you know any websites for mysql question?

I do submit the mysql forum but I would like to have more to learn

Now I have mysql replication question.

Thank you


  
__
Ask a question on any topic and get answers from real people. Go to  
Yahoo! Answers and share what you know at http://ca.answers.yahoo.com



--
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] system() Question

2008-12-28 Thread Nathan Nobbe
On Sun, Dec 28, 2008 at 12:40 PM, Ryan O'Sullivan r...@rynet.com wrote:

 Hello all,

 I am using system to convert some files using a binary in linux.  My code
 looks like this:
 $response = system('gpsbabel -p  -r -t -i gpx -f test.gpx -o kml -F
 test2.kml', $retval);
 echo pResponse: , $response, /ppReturn Value: , $retval;

 The $retval is returning code 127 - Any ideas on why 
 this?http://www.php.net/unsub.php


you might try shell_exec() instead to see if you can get any more mileage.
the return value of shell_exec() is the output of the executed command.

-nathan


Re: [PHP] system() Question

2008-12-28 Thread Rick Pasotto
On Sun, Dec 28, 2008 at 12:40 PM, Ryan O'Sullivan r...@rynet.com wrote:

 Hello all,

 I am using system to convert some files using a binary in linux.  My code
 looks like this:
 $response = system('gpsbabel -p  -r -t -i gpx -f test.gpx -o kml -F 
 test2.kml', $retval);
 echo pResponse: , $response, /ppReturn Value: , $retval;

 The $retval is returning code 127 - Any ideas on why this?

You overlooked the ampersand in front of $retval. The syntax for
'system' is:

string system  ( string $command  [, int $return_var  ] )

You have to pass a pointer to the variable, not the variable itself.

-- 
Paper has a genius for multiplication that cannot be equaled anywhere
 else in nature. -- Hugh Keenleyside
Rick Pasottor...@niof.nethttp://www.niof.net

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



Re: [PHP] system() Question

2008-12-28 Thread Daniel Brown
On Sun, Dec 28, 2008 at 18:10, Rick Pasotto r...@niof.net wrote:

 You overlooked the ampersand in front of $retval. The syntax for
 'system' is:

 string system  ( string $command  [, int $return_var  ] )

 You have to pass a pointer to the variable, not the variable itself.

Actually, that's not entirely correct while the documentation
shows it as a reference variable, it's not actually required to be a
pointer.  And in either case, the OP had the error code returned
(127), and $retval would have nothing to do with causing the error.

What I would recommend trying is:

?php
exec('./gpsbabel -p  -r -t -i gpx -f test.gpx -o kml -F
test2.kml 21',$ret);
print_r($ret);
?

On a side note, I'm curious as to what 'gpsbabel' does.  I've
worked a bit with Keyhole markups and GIS overlays, etc.  Neat stuff.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] system() Question

2008-12-28 Thread Nathan Nobbe
On Sun, Dec 28, 2008 at 6:49 PM, Daniel Brown danbr...@php.net wrote:

 On Sun, Dec 28, 2008 at 18:10, Rick Pasotto r...@niof.net wrote:
 
  You overlooked the ampersand in front of $retval. The syntax for
  'system' is:
 
  string system  ( string $command  [, int $return_var  ] )
 
  You have to pass a pointer to the variable, not the variable itself.

 Actually, that's not entirely correct while the documentation
 shows it as a reference variable, it's not actually required to be a
 pointer.


good point dan, and just to add further clarification, thats b/c the
function specifies $return_var is passed by reference in the formal
parameter.  when you include the  along w/ an actual parameter (during
function invocation) thats referred to as call-time-pass-by-reference in
php, and its typically frowned upon.  in fact, i think its being removed
from a future version of php.

-nathan


Re: [PHP] system() Question

2008-12-28 Thread Micah Gersten
Nathan Nobbe wrote:
 good point dan, and just to add further clarification, thats b/c the
 function specifies $return_var is passed by reference in the formal
 parameter.  when you include the  along w/ an actual parameter (during
 function invocation) thats referred to as call-time-pass-by-reference in
 php, and its typically frowned upon.  in fact, i think its being removed
 from a future version of php.

 -nathan

   
You don't call system using the ampersand.  The reference is declared in
the function definition.  There's no reason for this to be frowned
upon.   What you are referring to is the old PHP4 style of explicit
pass-by-reference in function usage which is frowned upon.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


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



Re: [PHP] system() Question

2008-12-28 Thread Nathan Nobbe
On Sun, Dec 28, 2008 at 8:40 PM, Micah Gersten mi...@onshore.com wrote:

 Nathan Nobbe wrote:
  good point dan, and just to add further clarification, thats b/c the
  function specifies $return_var is passed by reference in the formal
  parameter.  when you include the  along w/ an actual parameter (during
  function invocation) thats referred to as call-time-pass-by-reference in
  php, and its typically frowned upon.  in fact, i think its being removed
  from a future version of php.
 
  -nathan
 
 
 You don't call system using the ampersand.  The reference is declared in
 the function definition.  There's no reason for this to be frowned
 upon.


well i dont think they deprecated it for shits--giggles.

http://us.php.net/manual/en/language.references.pass.php

its disabled by default in php.ini; wonder why.. ;)


   What you are referring to is the old PHP4 style of explicit
 pass-by-reference in function usage which is frowned upon.


no im referring to call-time-pass by reference, which works just as well in
php5; as long as you enable it in php.ini (or one of the other various
ways).

and also, for clarification, marking parameters as pass-by-reference works
during method definition in php4 as well, of course.

-nathan


Re: [PHP] fread question

2008-12-18 Thread MikeP
From my phpinfo:
  magic_quotes_runtime Off

Robert Cummings rob...@interjinn.com wrote in message 
news:1229567238.8302.35.ca...@localhost...
 On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
 Hello,
 I have been trying to use fread to open a file, but it always escapes
 special characters.
 How do I open  afile without it modifying my original file:

 $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
 I use this and get slashes everywhere.This kills my REGex that gets coded
 next.

 Check this magically shitty setting in your php.ini:

magic_quotes_runtime

 It should be off unless someone with less brains than a turd got a hold
 of your ini file.

 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



Re: [PHP] fread question

2008-12-18 Thread MikeP
But this one is ON
magic_quotes_gpc
Robert Cummings rob...@interjinn.com wrote in message 
news:1229567238.8302.35.ca...@localhost...
 On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
 Hello,
 I have been trying to use fread to open a file, but it always escapes
 special characters.
 How do I open  afile without it modifying my original file:

 $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
 I use this and get slashes everywhere.This kills my REGex that gets coded
 next.

 Check this magically shitty setting in your php.ini:

magic_quotes_runtime

 It should be off unless someone with less brains than a turd got a hold
 of your ini file.

 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



Re: [PHP] fread question

2008-12-18 Thread MikeP
Still having problems:
magic_quotes_runtime is off
BUT
magic_quotes_gpc is on
I cant change them myself so I tried
stripslashes
That doesnt work though:

$_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
$test=$_POST[$fname];
$test3=stripslashes($test);

$test3 and $test are the same.

Any other Ideas?

Thanks
mike



Robert Cummings rob...@interjinn.com wrote in message 
news:1229567238.8302.35.ca...@localhost...
 On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
 Hello,
 I have been trying to use fread to open a file, but it always escapes
 special characters.
 How do I open  afile without it modifying my original file:

 $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
 I use this and get slashes everywhere.This kills my REGex that gets coded
 next.

 Check this magically shitty setting in your php.ini:

magic_quotes_runtime

 It should be off unless someone with less brains than a turd got a hold
 of your ini file.

 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



RE: [PHP] fread question

2008-12-18 Thread Boyd, Todd M.
 -Original Message-
 From: MikeP [mailto:mpel...@princeton.edu]
 Sent: Thursday, December 18, 2008 7:33 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] fread question
 
 Still having problems:
 magic_quotes_runtime is off
 BUT
 magic_quotes_gpc is on
 I cant change them myself so I tried
 stripslashes
 That doesnt work though:
 
 $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
 $test=$_POST[$fname];
 $test3=stripslashes($test);
 
 $test3 and $test are the same.
 
 Any other Ideas?
 
 Robert Cummings rob...@interjinn.com wrote in message
 news:1229567238.8302.35.ca...@localhost...
  On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
  Hello,
  I have been trying to use fread to open a file, but it always
 escapes
  special characters.
  How do I open  afile without it modifying my original file:
 
  $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
  I use this and get slashes everywhere.This kills my REGex that gets
 coded
  next.
 
  Check this magically shitty setting in your php.ini:
 
 magic_quotes_runtime
 
  It should be off unless someone with less brains than a turd got a
 hold
  of your ini file.

The PHP site's page on ini_set() [1] talks a bit about how to set that
particular option in an .htaccess file:

set PHP_INI_PERDIR settings in a .htaccess file with 'php_flag'
like this:

php_flag register_globals off
php_flag magic_quotes_gpc on

If you can get at your .htaccess, maybe you could do it that way (since
I don't believe you can change magic_quotes_gpc using ini_set() or
similar methods).

HTH,


// Todd

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



RE: [PHP] fread question

2008-12-18 Thread Boyd, Todd M.
Hah! Forgot to add the link:

1. http://php.net/ini_set

How would you guys have ever figured out that was the page on PHP's
website you need to visit in order to view information about the
ini_set() function?!

;)


// Todd

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



Re: [PHP] fread question

2008-12-18 Thread ceo

PHP does *not* do the addslashes on $_POST when you cram something into it in 
your PHP code.



It does it during the process of auto-filling up $_POST.



So either:

A) you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.

B) you actually managed to put the backslashes into your text file.



PS

You really shouldn't be cramming data into $_POST, imho.

Too confusing for later development/maintenance.

$_POST should be read only

Copy the parts of $_POST you want into something else, and add in your file 
contents as well.



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



Re: [PHP] fread question

2008-12-18 Thread MikeP
 you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.
NOmagic_quotes_runtime Off

 you actually managed to put the backslashes into your text file.
NO
tdinput name=letter type=file id=letter size=50 maxlength=255 
/
.
.
.
.
?php
process_uploaded_file('letter');
function process_uploaded_file($fname) {
// Assumes set of $_POST variables in the form: name, name_fname, 
name_size, name_type
$_POST[$fname.'_fname'] = $_FILES[$fname]['name'];
$_POST[$fname.'_size'] = $_FILES[$fname]['size'];
$_POST[$fname.'_type'] = $_FILES[$fname]['type'];
$_POST[$fname.'_fname'] = strtr($_POST[$fname.'_fname'],' 
%*;:{}[]|\,/()%...@!',''); //fix special chars in 
name
$_POST[$fname.'_fname'] = strtr($_POST[$fname.'_fname'],',_);
$fileHandle = fopen($_FILES[$fname]['tmp_name'], r);
$_POST[$fname] =stripslashes(fread($fileHandle, 
$_POST[$fname.'_size']));


Neither

c...@l-i-e.com wrote in message 
news:20081218155854.69674.qm...@o2.hostbaby.com...

 PHP does *not* do the addslashes on $_POST when you cram something into it 
 in your PHP code.

 It does it during the process of auto-filling up $_POST.

 So either:
 A) you have magic_quotes_runtime turned on LOCALLY. Use phpinfo() to see.
 B) you actually managed to put the backslashes into your text file.

 PS
 You really shouldn't be cramming data into $_POST, imho.
 Too confusing for later development/maintenance.
 $_POST should be read only
 Copy the parts of $_POST you want into something else, and add in your 
 file contents as well.
 



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



Re: [PHP] fread question

2008-12-17 Thread Robert Cummings
On Wed, 2008-12-17 at 19:54 -0500, MikeP wrote:
 Hello,
 I have been trying to use fread to open a file, but it always escapes 
 special characters.
 How do I open  afile without it modifying my original file:
 
 $_POST[$fname] = fread($fileHandle, $_POST[$fname.'_size']);
 I use this and get slashes everywhere.This kills my REGex that gets coded 
 next.

Check this magically shitty setting in your php.ini:

magic_quotes_runtime

It should be off unless someone with less brains than a turd got a hold
of your ini file.

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



Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Dan Joseph
On Thu, Dec 11, 2008 at 2:01 PM, Ólafur Waage olaf...@gmail.com wrote:

 I should be able to set a session var and then do a header redirect
 right? Small bug regarding that and i just need to be sure.

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


Yep, what bug are you running into?  Remember you have session_start() on
the next page for it to be there.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Daniel Brown
On Thu, Dec 11, 2008 at 14:01, Ólafur Waage olaf...@gmail.com wrote:
 I should be able to set a session var and then do a header redirect
 right? Small bug regarding that and i just need to be sure.

This isn't a bug in PHP, it's actually in adherance with HTTP
standards (and current browser standards).  Prior to doing a header()
redirect, you have to force the cookie to be written with
session_write_close().

-- 
/Daniel P. Brown
http://www.parasane.net/
daniel.br...@parasane.net || danbr...@php.net
50% Off Hosting! http://www.pilotpig.net/specials.php

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



[PHP] Re: [PHP-QA] Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Daniel Brown
(Forwarding back to PHP General for the archives.)

On Thu, Dec 11, 2008 at 14:31, Ólafur Waage olaf...@gmail.com wrote:
 Its fixed, thanks guys :)

 On Thu, Dec 11, 2008 at 7:16 PM, Daniel Brown danbr...@php.net wrote:
 On Thu, Dec 11, 2008 at 14:01, Ólafur Waage olaf...@gmail.com wrote:
 I should be able to set a session var and then do a header redirect
 right? Small bug regarding that and i just need to be sure.

This isn't a bug in PHP, it's actually in adherance with HTTP
 standards (and current browser standards).  Prior to doing a header()
 redirect, you have to force the cookie to be written with
 session_write_close().

 --
 /Daniel P. Brown
 http://www.parasane.net/
 daniel.br...@parasane.net || danbr...@php.net
 50% Off Hosting! http://www.pilotpig.net/specials.php


 --
 PHP Quality Assurance Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
/Daniel P. Brown
http://www.parasane.net/
daniel.br...@parasane.net || danbr...@php.net
50% Off Hosting! http://www.pilotpig.net/specials.php

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



[PHP] Re: [PHP-QA] Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Ólafur Waage
Whoops, sent the thanks to the wrong list :P

On Thu, Dec 11, 2008 at 7:33 PM, Daniel Brown danbr...@php.net wrote:
 (Forwarding back to PHP General for the archives.)

 On Thu, Dec 11, 2008 at 14:31, Ólafur Waage olaf...@gmail.com wrote:
 Its fixed, thanks guys :)

 On Thu, Dec 11, 2008 at 7:16 PM, Daniel Brown danbr...@php.net wrote:
 On Thu, Dec 11, 2008 at 14:01, Ólafur Waage olaf...@gmail.com wrote:
 I should be able to set a session var and then do a header redirect
 right? Small bug regarding that and i just need to be sure.

This isn't a bug in PHP, it's actually in adherance with HTTP
 standards (and current browser standards).  Prior to doing a header()
 redirect, you have to force the cookie to be written with
 session_write_close().

 --
 /Daniel P. Brown
 http://www.parasane.net/
 daniel.br...@parasane.net || danbr...@php.net
 50% Off Hosting! http://www.pilotpig.net/specials.php


 --
 PHP Quality Assurance Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php





 --
 /Daniel P. Brown
 http://www.parasane.net/
 daniel.br...@parasane.net || danbr...@php.net
 50% Off Hosting! http://www.pilotpig.net/specials.php


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



Re: [PHP] array_intersect question

2008-12-10 Thread German Geek
On Tue, Dec 2, 2008 at 11:06 PM, Andrej Kastrin [EMAIL PROTECTED]wrote:

 It works like a charm.

 Thanks, Andrej

 Tim | iHostNZ wrote:

 I know there must be a more elegant way with array_reduce or something,
 but
 I would simply write a function called

 function array_intersect_m($m_array) {
  $intersection = $m_array[0];
  for ($i=1; $i  count($m_array); $i++) {
$intersection = array_intersect($m_array[$i], $intersection);
  }
  return $intersection;
 }

 and put that into my library. O and while i'm at it, the array_reduce way
 would prob be:
 $m_array =
 array(array(green,red,blue),array(green,yellow,red),array(green,red,purple),array(green,red,yellow));
 array_reduce($m_array, 'array_intersect');


I tried this now with array_reduce and it didn't work as i expected. Can
anyone tell me why?
It says argument #1 to array_intersect is not an array, although i have an
array of arrays. Also tried providing $arrayOfArrays[0] as the third
parameter to array_reduce which had the same error.

Thanks,
Tim


Re: [PHP] array_intersect question

2008-12-02 Thread Tim | iHostNZ
I know there must be a more elegant way with array_reduce or something, but
I would simply write a function called

function array_intersect_m($m_array) {
  $intersection = $m_array[0];
  for ($i=1; $i  count($m_array); $i++) {
$intersection = array_intersect($m_array[$i], $intersection);
  }
  return $intersection;
}

and put that into my library. O and while i'm at it, the array_reduce way
would prob be:
$m_array =
array(array(green,red,blue),array(green,yellow,red),array(green,red,purple),array(green,red,yellow));
array_reduce($m_array, 'array_intersect');

but this could be wrong, havent done much with these 'meta' functions.

Regards,
Tim


On Tue, Dec 2, 2008 at 10:24 PM, Andrej Kastrin [EMAIL PROTECTED]wrote:

 Dear all,

 I have to perform an intersection on array of arrays. The fact is that php
 does not support intersection on multidimensional arrays.

 So, the first simple example using only one dimensional arrays works well:

 $array1 = array(green, red, blue);
 $array2 = array(green, yellow, red);
 $array3 = array(green, red, purple);
 $array4 = array(green,red,yellow);
 $result = array_intersect($array1,$array2,$array3,$array4);
 print_r($result);

 And the result is: Array ( [0] = green [1] = red )

 The question is how to perform intersection on the following structure:

 $products =
 array(array(green,red,blue),array(green,yellow,red),array(green,red,purple),array(green,red,yellow));

 Thanks in advance for any suggestions.

 Best, Andrej

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




-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] array_intersect question

2008-12-02 Thread Andrej Kastrin

It works like a charm.

Thanks, Andrej

Tim | iHostNZ wrote:

I know there must be a more elegant way with array_reduce or something, but
I would simply write a function called

function array_intersect_m($m_array) {
  $intersection = $m_array[0];
  for ($i=1; $i  count($m_array); $i++) {
$intersection = array_intersect($m_array[$i], $intersection);
  }
  return $intersection;
}

and put that into my library. O and while i'm at it, the array_reduce 
way would prob be:
$m_array = 
array(array(green,red,blue),array(green,yellow,red),array(green,red,purple),array(green,red,yellow));

array_reduce($m_array, 'array_intersect');

but this could be wrong, havent done much with these 'meta' functions.

Regards,
Tim


On Tue, Dec 2, 2008 at 10:24 PM, Andrej Kastrin 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


Dear all,

I have to perform an intersection on array of arrays. The fact is
that php does not support intersection on multidimensional arrays.

So, the first simple example using only one dimensional arrays works
well:

$array1 = array(green, red, blue);
$array2 = array(green, yellow, red);
$array3 = array(green, red, purple);
$array4 = array(green,red,yellow);
$result = array_intersect($array1,$array2,$array3,$array4);
print_r($result);

And the result is: Array ( [0] = green [1] = red )

The question is how to perform intersection on the following structure:

$products =

array(array(green,red,blue),array(green,yellow,red),array(green,red,purple),array(green,red,yellow));

Thanks in advance for any suggestions.

Best, Andrej

-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




--
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


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



Re: [PHP] array_intersect question

2008-12-02 Thread Yeti
 The question is how to perform intersection on the following structure:

 $products =
 array(array(green,red,blue),array(green,yellow,red),array(green,red,purple),array(green,red,yellow));

If I understood you correctly ..

?php
$arr = array();
$arr[] = array(green, red, blue);
$arr[] = array(green, yellow, red);
$arr[] = array(green, red, purple);
$arr[] = array(green,red,yellow);
var_dump($arr);
// you could also ..
$arr = array();
array_push(
$arr, array(green, red, blue),
array(green, yellow, red),
array(green, red, purple),
array(green,red,yellow)
);
var_dump($arr);
?

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



Re: [PHP] [php] question about ob_end_flush

2008-11-27 Thread Robert Cummings
On Fri, 2008-11-28 at 12:01 +0800, jason liang wrote:
 Hi all
 
 I am comfused about the function ob_end_flush.In the manual:This function
 will send the contents of the topmost output buffer (if any) and turn this
 output buffer off.
 
 i have made such tests.
 
 ?php
 ob_start();
 echo hello word!;
 ob_end_flush();
 ?
 this works alright.the script output hello world!.
 
 ?php
 ob_start();
 echo hello word!;
 ob_end_flush();

Right here you said to end the current buffer... which means the active
output buffer becomes the next outer one.

ob_clean();

Here you've told the current buffer to purge. So you've essentially
wiped everything that was flushed from the previous inner buffer to the
current buffer. So you see nothing. Why is there an outer buffer? You
probably have output buffering enabled in your php.ini (see
output_buffering in php.ini).

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



RE: [PHP] while-question

2008-11-19 Thread bruce
interesting points regarding college and programming..

my degrees bsee/msee covered alot more than pure programing.. as a double 
ee/cs, the ability to articulate an issue/problem, and bring to mind a cogent 
thought process was valuable. the ability to understand how different 
algorithms worked, and how code actually played with the lower intracacies of 
the processor where quite valuable. 

and no.. i'm no longer the engineer i was a time ago..

so.. interesting...


-Original Message-
From: Wolf [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17, 2008 11:55 AM
To: tedd
Cc: php-general@lists.php.net
Subject: RE: [PHP] while-question


 Dabbling?
 
 I think that making a living from it isn't dabbling, so I may not be 
 qualified to speak for the dabblers.
 
 But for me, I was writing code before there were such courses. Later, 
 when I went to college I was taught adventures in keypunching and 
 received several next to worthless degrees.
 
 I say next to worthless only because what they taught really wasn't 
 applicable to real world programming. As for management, clients, and 
 hr types, the degrees mattered, but not for much more than that.
 
 In any event, I doubt if any college courses are keeping up with 
 current web technology -- there has always been a lag between what's 
 practiced and what's taught. What I've seen of college web sites, 
 seems to support that claim.
 
 If I was taught in college all I needed to know, then what am I doing 
 with these dozens of web books scattered about my office? I probably 
 read a new book every other week.

I don't dabble in it either, unless you consider making my living from being 
a dabbler, in which case I'll continue to dabble and see the pay for it.  My 
alma-mater tried to stay current to some degree, but when they let someone who 
wrote the C++ book try to teach it, well they gave that person more rope then 
they needed.

Tedd, glad you got hooked on Phonics.  One of these days I hope from graduating 
from just looking at the pictures, but right now the pictures are oh so 
enticing!. ;)  

Wolf

-- 
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] while-question

2008-11-19 Thread Shawn McKenzie
bruce wrote:
 interesting points regarding college and programming..
 
 my degrees bsee/msee covered alot more than pure programing.. as a double 
 ee/cs, the ability to articulate an issue/problem, and bring to mind a cogent 
 thought process was valuable. the ability to understand how different 
 algorithms worked, and how code actually played with the lower intracacies of 
 the processor where quite valuable. 
 
 and no.. i'm no longer the engineer i was a time ago..
 
 so.. interesting...
 

They must have been case-insensitive languages, unlike English.  :-)

-Shawn

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



Re: [PHP] while question

2008-11-18 Thread Nathan Rixham

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 18:01 -0500, Craige Leeder wrote:

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
  
Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige


Can you do that? I assume it would look like this:

foreach($array as $a) {}
  

Close. It actually looks like this:

foreach ($array as $key = $value)  {}

This makes sense because for each  iteration of the loop, PHP places a 
copy of the key in $key, and a copy of the value in $value. Therefor, 
you are specifying with this code that you want it to place a reference 
of the value into $value.


- Craige




Ah, that could be very useful to know, thanks!


Ash
www.ashleysheridan.co.uk



foreach ($array as $key = $value)

$value = a copy so won't change the original array
$array[$key] = the original

thus:

foreach ($array as $key = $value) {
 $array[$key] = do_something_with($value);
}

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



Re: [PHP] while-question

2008-11-18 Thread Nathan Rixham

tedd wrote:

At 7:02 PM -0500 11/17/08, Craige Leeder wrote:

I'm not illiterate; promise :p

- Craige



Yeah, his parents were married before he was born.

Cheers,

tedd



omg tedd, I was just reading this thread over, thought exactly that 
witty response, clicked you're reply and there it is; masterful!


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



Re: [PHP] while-question

2008-11-18 Thread Craige Leeder

Jochem Maas wrote:

just for laughs .. given the 'dabble' thread Cleeder is phonetically
very very close to a dutch word meaning 'messing around' .. rather in the way
a 2yo might mess around with a bowl of yogurt.
  
Haha, now that does make me laugh. Out of curiosity, what is the actual 
word for it?


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



Re: [PHP] while-question

2008-11-18 Thread Jochem Maas
Craige Leeder schreef:
 Jochem Maas wrote:
 just for laughs .. given the 'dabble' thread Cleeder is phonetically
 very very close to a dutch word meaning 'messing around' .. rather in
 the way
 a 2yo might mess around with a bowl of yogurt.
   
 Haha, now that does make me laugh. Out of curiosity, what is the actual
 word for it?  

klieder ... kliederen

the E sound is short.

 


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



Re: [PHP] while-question

2008-11-18 Thread Craige Leeder

Jochem Maas wrote:

klieder ... kliederen

the E sound is short.

  

Interesting to know. Thanks :D

- Craige

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



Re: [PHP] while-question

2008-11-18 Thread Nathan Rixham

Craige Leeder wrote:

Jochem Maas wrote:

klieder ... kliederen

the E sound is short.

  

Interesting to know. Thanks :D

- Craige


don't believe him, jochem is really called Bob Davis, a slightly 
balding middle aged ASP developer from hull sent to infiltrate the PHP 
community and misguide the weak with tales of short sounding letters.


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



Re: [PHP] while-question

2008-11-18 Thread Bastien Koert
On Tue, Nov 18, 2008 at 9:33 AM, Nathan Rixham [EMAIL PROTECTED] wrote:

 Craige Leeder wrote:

 Jochem Maas wrote:

 klieder ... kliederen

 the E sound is short.



 Interesting to know. Thanks :D

 - Craige


 don't believe him, jochem is really called Bob Davis, a slightly balding
 middle aged ASP developer from hull sent to infiltrate the PHP community and
 misguide the weak with tales of short sounding letters.


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


Is this where we starting singing

'Pass the dutchie on the left hand side'?



-- 

Bastien

Cat, the other other white meat


Re: [PHP] while-question

2008-11-18 Thread Robert Cummings
On Tue, 2008-11-18 at 14:33 +, Nathan Rixham wrote:
 Craige Leeder wrote:
  Jochem Maas wrote:
  klieder ... kliederen
 
  the E sound is short.
 

  Interesting to know. Thanks :D
  
  - Craige
 
 don't believe him, jochem is really called Bob Davis, a slightly 
 balding middle aged ASP developer from hull

Ahhh... Hull... I have memories of thee. 15 years ago between 1am and
3am that was the place to head after the Ottawa bars closed and you
wanted to squeeze in another 2 hours of binging.

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



Re: [PHP] while question

2008-11-18 Thread Ashley Sheridan
On Tue, 2008-11-18 at 10:52 +, Nathan Rixham wrote:
 Ashley Sheridan wrote:
  On Mon, 2008-11-17 at 18:01 -0500, Craige Leeder wrote:
  Ashley Sheridan wrote:
  On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:

  Only thing to note with the foreach is that you are actually working on 
  a copy of the array, so if you intend to modify it, pass it by reference.
 
  - Craige
  
  Can you do that? I assume it would look like this:
 
  foreach($array as $a) {}

  Close. It actually looks like this:
 
  foreach ($array as $key = $value)  {}
 
  This makes sense because for each  iteration of the loop, PHP places a 
  copy of the key in $key, and a copy of the value in $value. Therefor, 
  you are specifying with this code that you want it to place a reference 
  of the value into $value.
 
  - Craige
 
 
 
  Ah, that could be very useful to know, thanks!
  
  
  Ash
  www.ashleysheridan.co.uk
  
 
 foreach ($array as $key = $value)
 
 $value = a copy so won't change the original array
 $array[$key] = the original
 
 thus:
 
 foreach ($array as $key = $value) {
   $array[$key] = do_something_with($value);
 }
 
This is how I've always done it 'til now, but I think passing by
reference is a bit neater in its approach, and can be easier to read
when $value is itself an array or complex object.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while question

2008-11-17 Thread Stut

On 17 Nov 2008, at 13:01, Alain Roger wrote:
i'm on PHP training and our lector is telling us that to avoid  
counting an

array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i = $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.


The while would work if you removed elements of $my_array inside the  
loop, but you would still need to be sure that it would eventually be  
empty.


I would guess that your lecturers point is that you shouldn't call  
count on every iteration as it's a waste of time. He may also be  
confusing while for foreach in which case I'd leave because you're  
unlikely to learn anything from him.


-Stut

--
http://stut.net/


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



Re: [PHP] while question

2008-11-17 Thread Thodoris



Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i = $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.

  


Probably the easiest way for doing this is using foreach:

$a = array(1,2,3,4,5);

foreach ($a as $i) {
   print $i.br;
}

This outputs:
1
2
3
4
5

This for e.g. gives an infinite loop:

$a = array(1,2,3,4,5);

while ($a) {
   print $i.br;
   $i++;
}

So you are right because $a will always evaluate as true since it not 
empty. For these kinds of questions you should read the manual first and 
then ask here.


http://gr2.php.net/manual/en/control-structures.while.php

--
Thodoris


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



RE: [PHP] while question

2008-11-17 Thread Jay Blanchard
[snip]
...foreach...
[/snip]

You could also use a for loop if you wanted to count;

for($i = 0; $i  count($array); $i++){
   echo $i . \n;
}



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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Timo Erbach schreef:
 ...but for best performance you should do:
 
 
 $counter = count($array);
 for($i = 0; $i  $counter; $i++){
   echo $i . \n;
 }

just for fun:

$a = range(1,10);
for ($i = 0, $c = count($a); $i  $c; print($a[$i].\n), $i++);

... gives an idea of the power and flexibility of a for loop
constructor, i.e. you can pretty much write a complete program
using just a for construct without even defining a loop body.

 
 So the expression count() in the for()-loop is only
 parsed once and not every loop.
 
 Regards
 Timo
 [snip]
 ...foreach...
 [/snip]
 
 You could also use a for loop if you wanted to count;
 
 for($i = 0; $i  count($array); $i++){
   echo $i . \n;
 }
 
 


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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

Jochem Maas wrote:

$a = range(1,10);
for ($i = 0, $c = count($a); $i  $c; print($a[$i].\n), $i++);


think the point of this is to count the items in an array without count 
mate :p no point in the above you could just:

$c = count($a);

foreach!
$a = range(1,10);
$c = 0;
foreach($a as $b) {
 $c++;
}
echo $c. PHP_EOL;

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using the + 
operator. fill it in:


function add($a , $b) {
 //code here but no + - / * operators
 return $answer;
}

echo add(5, 17);

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



RE: [PHP] Another question about Google maps

2008-11-17 Thread Boyd, Todd M.
 -Original Message-
 From: tedd [mailto:[EMAIL PROTECTED]
 Sent: Saturday, November 15, 2008 2:11 PM
 To: php-general@lists.php.net
 Subject: [PHP] Another question about Google maps
 
 Hi gang:
 
 I posted this question on the Google Map Discussion group/list
 thingie, but got zip in replies. Maybe someone here might have an
 idea.
 
 Here's the url:
 
 http://masoncollision.com/contact.php
 
 In both Safari and FireFox for the Mac (I have not tested it with
 other browsers) as the page loads the map border is momentary drawn
 twice. The map border is shown stacked one above the other making the
 page much longer than it actually is. But immediately thereafter, the
 map is drawn correctly and the page returns to the size it's supposed
 to be.
 
 I just want to get rid of the momentary flash.
 
 Anyone have any ideas?

tedd, I think it might be displaying your extra divs (if there are any..
just skimmed the source momentarily) for a split second before they are
hidden with Javascript. Maybe try setting the CSS for your 3 map divs
(mapsearch, idlediv, searchdiv or whatever) to display:none and show
them when the page is loaded? Or give all 3 the same top/left
coordinates, etc...

Just a shot in the dark. I may read over the code a bit more if I get
some time later today. I'm no expert, but I've been working with the
Google Maps API rather extensively lately, and maybe I can offer a fresh
set of eyes.

HTH,


Todd Boyd
Web Programmer

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Nathan Rixham schreef:
 Jochem Maas wrote:
 $a = range(1,10);
 for ($i = 0, $c = count($a); $i  $c; print($a[$i].\n), $i++);
 
 think the point of this is to count the items in an array without count
 mate :p no point in the above you could just:
 $c = count($a);

I thought the point was to avoid count() on every iteration.
not using count() but instead looping the complete array is stupid,
if the OP's teacher thinks count() is bad then that teacher suck's,
count() is efficient as it can be ... it does'nt actually do a
count when it's called merely looks up the length property of the
array (unless I'm grossly mistaken)

 
 foreach!
 $a = range(1,10);
 $c = 0;
 foreach($a as $b) {
  $c++;
 }
 echo $c. PHP_EOL;
 
 if you really want a challenge try this one..
 
 task: add the numbers 5 and 17 together, using php, without using the +
 operator. fill it in:
 
 function add($a , $b) {
  //code here but no + - / * operators

I'll assume no post/pre-increment operators either.

  return $answer;
 }
 
 echo add(5, 17);

function add($a, $b) {
$a = array_merge(array_fill(0, $a, 1), array_fill(0, $b, 1));
return count($a);
}

not very efficient :-) .. probably one of a 1000 ways to fudge it :-)

 


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



Re: [PHP] while-question

2008-11-17 Thread Stut

On 17 Nov 2008, at 14:31, Nathan Rixham wrote:

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using  
the + operator. fill it in:


function add($a , $b) {
//code here but no + - / * operators
return $answer;
}

echo add(5, 17);


Elemental my dear Mr Rixham...

function add($a , $b)
{
  $answer = $a ^ $b;
  while (0 != ($a  $b))
  {
$b = ($a  $b)  1;
$answer = $answer ^ $b;
  }
  return $answer;
}

-Stut

--
http://stut.net/

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



Re: [PHP] while-question

2008-11-17 Thread Andrew Ballard
On Mon, Nov 17, 2008 at 9:47 AM, Jochem Maas [EMAIL PROTECTED] wrote:
 Nathan Rixham schreef:
 Jochem Maas wrote:
 $a = range(1,10);
 for ($i = 0, $c = count($a); $i  $c; print($a[$i].\n), $i++);

 think the point of this is to count the items in an array without count
 mate :p no point in the above you could just:
 $c = count($a);

 I thought the point was to avoid count() on every iteration.
 not using count() but instead looping the complete array is stupid,
 if the OP's teacher thinks count() is bad then that teacher suck's,
 count() is efficient as it can be ... it does'nt actually do a
 count when it's called merely looks up the length property of the
 array (unless I'm grossly mistaken)


 foreach!
 $a = range(1,10);
 $c = 0;
 foreach($a as $b) {
  $c++;
 }
 echo $c. PHP_EOL;

 if you really want a challenge try this one..

 task: add the numbers 5 and 17 together, using php, without using the +
 operator. fill it in:

 function add($a , $b) {
  //code here but no + - / * operators

 I'll assume no post/pre-increment operators either.

  return $answer;
 }

 echo add(5, 17);

 function add($a, $b) {
$a = array_merge(array_fill(0, $a, 1), array_fill(0, $b, 1));
return count($a);
 }

 not very efficient :-) .. probably one of a 1000 ways to fudge it :-)


And another... :)

function add($a, $b) {
return array_sum(func_get_args());
}

Andrew

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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

Stut wrote:

On 17 Nov 2008, at 14:31, Nathan Rixham wrote:

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using the 
+ operator. fill it in:


function add($a , $b) {
//code here but no + - / * operators
return $answer;
}

echo add(5, 17);


Elemental my dear Mr Rixham...

function add($a , $b)
{
  $answer = $a ^ $b;
  while (0 != ($a  $b))
  {
$b = ($a  $b)  1;
$answer = $answer ^ $b;
  }
  return $answer;
}

-Stut



what an answer; very nice and indeed full marks mr stut!

now then..
echo add(5,17) . ' ' . (5 + 17) . PHP_EOL;
echo add(-5,17) . ' ' . (-5 + 17) . PHP_EOL;
echo add(5,-17) . ' ' . (5 + -17) . PHP_EOL;
echo add(-5,-17) . ' ' . (-5 + -17) . PHP_EOL;

(can you tell I've been down this route before?)

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



RE: [PHP] Another question about Google maps

2008-11-17 Thread tedd

At 8:37 AM -0600 11/17/08, Boyd, Todd M. wrote:

tedd, I think it might be displaying your extra divs (if there are any..
just skimmed the source momentarily) for a split second before they are
hidden with Javascript. Maybe try setting the CSS for your 3 map divs
(mapsearch, idlediv, searchdiv or whatever) to display:none and show
them when the page is loaded? Or give all 3 the same top/left
coordinates, etc...

Just a shot in the dark. I may read over the code a bit more if I get
some time later today. I'm no expert, but I've been working with the
Google Maps API rather extensively lately, and maybe I can offer a fresh
set of eyes.

HTH,


Todd Boyd
Web Programmer


Todd:

That would be great. Also, if you see anything there you like, of 
course you may use it.


I think the div's are Okay -- I always check my code through the W3C 
validator and that does a good job of checking that. I wish that 
Google and W3C would decide on what's acceptable.


I also tried display: none via css, but could not get the right 
combination of hide/display to make it work right. However, I'll look 
into your suggestion.


If you can find anything to correct, that would be good. But it's 
just a minor annoyance and I thought someone might readily know what 
the problem was.


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] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 14:54 +, Stut wrote:
 On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
  if you really want a challenge try this one..
 
  task: add the numbers 5 and 17 together, using php, without using  
  the + operator. fill it in:
 
  function add($a , $b) {
  //code here but no + - / * operators
  return $answer;
  }
 
  echo add(5, 17);
 
 Elemental my dear Mr Rixham...

What level is that elemental?

 function add($a , $b)
 {
$answer = $a ^ $b;
while (0 != ($a  $b))
{
  $b = ($a  $b)  1;
  $answer = $answer ^ $b;
}
return $answer;
 }

He only said you couldn't use the + operator... nothing was said about
using the - operator.

$total = -(-5 - 17);

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



RE: [PHP] while-question

2008-11-17 Thread bruce
curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17, 2008 9:53 AM
To: Stut
Cc: Nathan Rixham; php-general@lists.php.net
Subject: Re: [PHP] while-question


On Mon, 2008-11-17 at 14:54 +, Stut wrote:
 On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
  if you really want a challenge try this one..
 
  task: add the numbers 5 and 17 together, using php, without using
  the + operator. fill it in:
 
  function add($a , $b) {
  //code here but no + - / * operators
  return $answer;
  }
 
  echo add(5, 17);

 Elemental my dear Mr Rixham...

What level is that elemental?

 function add($a , $b)
 {
$answer = $a ^ $b;
while (0 != ($a  $b))
{
  $b = ($a  $b)  1;
  $answer = $answer ^ $b;
}
return $answer;
 }

He only said you couldn't use the + operator... nothing was said about
using the - operator.

$total = -(-5 - 17);

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


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Robert Cummings schreef:
 On Mon, 2008-11-17 at 14:54 +, Stut wrote:
 On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
 if you really want a challenge try this one..

 task: add the numbers 5 and 17 together, using php, without using  
 the + operator. fill it in:

 function add($a , $b) {
 //code here but no + - / * operators
 return $answer;
 }

 echo add(5, 17);
 Elemental my dear Mr Rixham...
 
 What level is that elemental?

well it's all bitwise operating ... can't get much more
elemental that a bit in CS. but I think he meant to
say elementary (assuming the Sherlocks Holmes catchphrase)

 
 function add($a , $b)
 {
$answer = $a ^ $b;
while (0 != ($a  $b))
{
  $b = ($a  $b)  1;
  $answer = $answer ^ $b;
}
return $answer;
 }

nice, I think :P

 He only said you couldn't use the + operator... nothing was said about
 using the - operator.

quote
//code here but no + - / * operators
/quote



 
 $total = -(-5 - 17);
 
 Cheers,
 Rob.


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



RE: [PHP] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 10:00 -0800, bruce wrote:
 curious qiestion
 
 to all on here who dabble in php... how many of you have actully gone to
 college, taken algorithm courses, microprocessor courses,
 design/architecture courses, etc..
 
 or is the majority of the work here from people who've grabbed the tools and
 started programming... ?

I think it's a mixed crowd here. I have a Bachelor of Computer Science.
The various algorithms courses were some of my favourite courses in the
program along with parallel and distributed computing.

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



Re: [PHP] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 19:07 +0100, Jochem Maas wrote:
 Robert Cummings schreef:
  On Mon, 2008-11-17 at 14:54 +, Stut wrote:
  On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
  if you really want a challenge try this one..
 
  task: add the numbers 5 and 17 together, using php, without using  
  the + operator. fill it in:
 
  function add($a , $b) {
  //code here but no + - / * operators
  return $answer;
  }
 
  echo add(5, 17);
  Elemental my dear Mr Rixham...
  
  What level is that elemental?
 
 well it's all bitwise operating ... can't get much more
 elemental that a bit in CS. but I think he meant to
 say elementary (assuming the Sherlocks Holmes catchphrase)
 
  
  function add($a , $b)
  {
 $answer = $a ^ $b;
 while (0 != ($a  $b))
 {
   $b = ($a  $b)  1;
   $answer = $answer ^ $b;
 }
 return $answer;
  }
 
 nice, I think :P
 
  He only said you couldn't use the + operator... nothing was said about
  using the - operator.
 
 quote
 //code here but no + - / * operators
 /quote

Oh... duh! :) You know what they say, if you're going to say something,
say it all in one place, not part of something in one place, and the
rest later on. Not everyone reads to the end you insensitive clod ;)

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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?



the bulk of it self taught and via vast amounts of reading and many 
years of on the job experience (needs must), some formal education in 
the form of a year wasted getting a diploma whenst I was young (mainly 
as the topics covered where out of date and unused in general business).


HOWEVER, (a big one) I've recently converted, never really been an 
advocate of formal training until recently; I would highly recommend 
taking some certification courses (zend, sun, mysql etc), and some 
formal study on the finer details of programming / architecture.


If I could do it all again I'd do both, work to get experience and 
challeges, read the great books and the manuals, and get certified 
properly at the same time.


finally, using good tools makes a vast difference, for instance I use 
eclipse + pdt + zend eclipse debugger + svn + rse + bugzilla + mylyn + 
phpdoc + phpunit (adding in ant + cruise control to the mix soon for 
continuous integration)


[snip myself]

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



RE: [PHP] while-question

2008-11-17 Thread tedd

At 10:00 AM -0800 11/17/08, bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?



Dabbling?

I think that making a living from it isn't dabbling, so I may not be 
qualified to speak for the dabblers.


But for me, I was writing code before there were such courses. Later, 
when I went to college I was taught adventures in keypunching and 
received several next to worthless degrees.


I say next to worthless only because what they taught really wasn't 
applicable to real world programming. As for management, clients, and 
hr types, the degrees mattered, but not for much more than that.


In any event, I doubt if any college courses are keeping up with 
current web technology -- there has always been a lag between what's 
practiced and what's taught. What I've seen of college web sites, 
seems to support that claim.


If I was taught in college all I needed to know, then what am I doing 
with these dozens of web books scattered about my office? I probably 
read a new book every other week.


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] while-question

2008-11-17 Thread Wolf
 Dabbling?
 
 I think that making a living from it isn't dabbling, so I may not be 
 qualified to speak for the dabblers.
 
 But for me, I was writing code before there were such courses. Later, 
 when I went to college I was taught adventures in keypunching and 
 received several next to worthless degrees.
 
 I say next to worthless only because what they taught really wasn't 
 applicable to real world programming. As for management, clients, and 
 hr types, the degrees mattered, but not for much more than that.
 
 In any event, I doubt if any college courses are keeping up with 
 current web technology -- there has always been a lag between what's 
 practiced and what's taught. What I've seen of college web sites, 
 seems to support that claim.
 
 If I was taught in college all I needed to know, then what am I doing 
 with these dozens of web books scattered about my office? I probably 
 read a new book every other week.

I don't dabble in it either, unless you consider making my living from being 
a dabbler, in which case I'll continue to dabble and see the pay for it.  My 
alma-mater tried to stay current to some degree, but when they let someone who 
wrote the C++ book try to teach it, well they gave that person more rope then 
they needed.

Tedd, glad you got hooked on Phonics.  One of these days I hope from graduating 
from just looking at the pictures, but right now the pictures are oh so 
enticing!. ;)  

Wolf

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



RE: [PHP] while-question

2008-11-17 Thread tedd

At 2:55 PM -0500 11/17/08, Wolf wrote:
Tedd, glad you got hooked on Phonics.  One of these days I hope from 
graduating from just looking at the pictures, but right now the 
pictures are oh so enticing!. ;) 


Wolf


Wolf:

Lot's of exciting things -- hard to keep up on bots, automated 
buying, data mining, and other such things that make my head hurt.


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] while question

2008-11-17 Thread Craige Leeder

Alain Roger wrote:

Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i = $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.
  
While you teacher technically is wrong, you probably could implement 
something using the next() and current() array functions, though you're 
best to just use a foreach loop. foreach was designed specifically as an 
array looping construct, so it's optimized pretty well.


Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige



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



Re: [PHP] while question

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
 Alain Roger wrote:
  Hi,
 
  i'm on PHP training and our lector is telling us that to avoid counting an
  array item amout thanks count($my_array), he tells we can do:
  while($my_array)
  {
   ... do something
  }
  but from experience this is an infinity loop...
 
  it should be always something like
  $count = count($my_array);
  while($i = $count)
  {
  ...
  do something
  ...
  $i++;
  }
 
  has someone already use such syntax ? i mean as the first one.
  thx.

 While you teacher technically is wrong, you probably could implement 
 something using the next() and current() array functions, though you're 
 best to just use a foreach loop. foreach was designed specifically as an 
 array looping construct, so it's optimized pretty well.
 
 Only thing to note with the foreach is that you are actually working on 
 a copy of the array, so if you intend to modify it, pass it by reference.
 
 - Craige
 
 
 
Can you do that? I assume it would look like this:

foreach($array as $a) {}


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while question

2008-11-17 Thread Craige Leeder

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
  
Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige


Can you do that? I assume it would look like this:

foreach($array as $a) {}
  


Close. It actually looks like this:

foreach ($array as $key = $value)  {}

This makes sense because for each  iteration of the loop, PHP places a 
copy of the key in $key, and a copy of the value in $value. Therefor, 
you are specifying with this code that you want it to place a reference 
of the value into $value.


- Craige



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



Re: [PHP] while question

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 18:01 -0500, Craige Leeder wrote:
 Ashley Sheridan wrote:
  On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:

  Only thing to note with the foreach is that you are actually working on 
  a copy of the array, so if you intend to modify it, pass it by reference.
 
  - Craige
  
  Can you do that? I assume it would look like this:
 
  foreach($array as $a) {}

 
 Close. It actually looks like this:
 
 foreach ($array as $key = $value)  {}
 
 This makes sense because for each  iteration of the loop, PHP places a 
 copy of the key in $key, and a copy of the value in $value. Therefor, 
 you are specifying with this code that you want it to place a reference 
 of the value into $value.
 
 - Craige
 
 
 
Ah, that could be very useful to know, thanks!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?
  


I'm 100% self taught for now. I'm just out of higschool, and hopefully 
going off to collage next year.


Everything I've learned at this stage is from books, tutorials, and 
experience.


- Craige

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
 bruce wrote:
 curious qiestion

 to all on here who dabble in php... how many of you have actully gone to
 college, taken algorithm courses, microprocessor courses,
 design/architecture courses, etc..

 or is the majority of the work here from people who've grabbed the
 tools and
 started programming... ?
   
 
 I'm 100% self taught for now. I'm just out of higschool, and hopefully
 going off to collage next year.

must  . resist 

I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?

 dang it, failed. ;-)


 Everything I've learned at this stage is from books, tutorials, and
 experience.
 
 - Craige
 


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
tedd schreef:
 At 10:00 AM -0800 11/17/08, bruce wrote:
 curious qiestion

 to all on here who dabble in php... how many of you have actully gone to
 college, taken algorithm courses, microprocessor courses,
 design/architecture courses, etc..

 or is the majority of the work here from people who've grabbed the
 tools and
 started programming... ?
 
 
 Dabbling?

Im neck deep in dabble every other week .. obviously it's always
someone else dabble ;-)


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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

Jochem Maas wrote:

must  . resist 

I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?

 dang it, failed. ;-)
  



Haha! 'high' was just my 'h' key not pressing, and college is just one 
of those words I have trouble with.



I'm not illiterate; promise :p

- Craige

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



Re: [PHP] while question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
 Ashley Sheridan wrote:
 On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
  
 Only thing to note with the foreach is that you are actually working
 on a copy of the array, so if you intend to modify it, pass it by
 reference.

 - Craige
 
 Can you do that? I assume it would look like this:

 foreach($array as $a) {}
   
 
 Close. It actually looks like this:
 
 foreach ($array as $key = $value)  {}
 
 This makes sense because for each  iteration of the loop, PHP places a
 copy of the key in $key, and a copy of the value in $value. Therefor,
 you are specifying with this code that you want it to place a reference
 of the value into $value.

indeed but beware, using a variable named $value after such a foreach loop
in the same scope will lead to all sorts of things you don't expect.

 
 - Craige
 
 
 


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



Re: [PHP] while-question

2008-11-17 Thread tedd

At 12:52 AM +0100 11/18/08, Jochem Maas wrote:

Craige Leeder schreef:
  I'm 100% self taught for now. I'm just out of higschool, and hopefully

 going off to collage next year.


must  . resist 

I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?

 dang it, failed. ;-)


Hang in there Jochem -- he's probably smarter than we were when we 
were his age.


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] while-question

2008-11-17 Thread tedd

At 7:02 PM -0500 11/17/08, Craige Leeder wrote:

I'm not illiterate; promise :p

- Craige



Yeah, his parents were married before he was born.

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] while question

2008-11-17 Thread Micah Gersten
Jay Blanchard wrote:
 [snip]
 ...foreach...
 [/snip]

 You could also use a for loop if you wanted to count;

 for($i = 0; $i  count($array); $i++){
echo $i . \n;
 }


   

This is not good because you are calling count every loop iteration.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
tedd schreef:
 At 12:52 AM +0100 11/18/08, Jochem Maas wrote:
 Craige Leeder schreef:
   I'm 100% self taught for now. I'm just out of higschool, and hopefully
  going off to collage next year.

 must  . resist 

 I take you didn't score to hig on the spelling test? and collage,
 is that the the cut-n-paste school of IT?

  dang it, failed. ;-)
 
 Hang in there Jochem -- he's probably smarter than we were when we were
 his age.

pity the poor soul ;-) being clever only gets you deeper into 'dabble'. :-P

 Cheers,
 
 tedd


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
 Jochem Maas wrote:
 must  . resist 

 I take you didn't score to hig on the spelling test? and collage,
 is that the the cut-n-paste school of IT?

  dang it, failed. ;-)
   
 
 
 Haha! 'high' was just my 'h' key not pressing, and college is just one
 of those words I have trouble with.

I demand credit for the utter brilliance of the cut-n-paste crack ;-)

 
 I'm not illiterate; promise :p

:-)

 
 - Craige

just for laughs .. given the 'dabble' thread Cleeder is phonetically
very very close to a dutch word meaning 'messing around' .. rather in the way
a 2yo might mess around with a bowl of yogurt.

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



<    1   2   3   4   5   6   7   8   9   10   >