Re: [PHP] a question about user and permission on linux

2010-10-31 Thread a...@ashleysheridan.co.uk
There isn't a php user. If php scripts are executed through the web server, 
they belong to the server. If they are cli scripts, then they belong to the 
user that executed them, or the user the process that executed them is running 
as.

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

- Reply message -
From: Ryan Sun ryansu...@gmail.com
Date: Sun, Oct 31, 2010 18:43
Subject: [PHP] a question about user and permission on linux
To: a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk

Then whats the user of php?
On 10/31/2010 2:39 PM, a...@ashleysheridan.co.uk wrote:
 If its Apache on Linux (as most hosting will be) then the user will 
 generally be either apache, www, or http.

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






[PHP] PHP Question

2010-10-28 Thread Paulo Work

Hello my name is Paulo Carvalho and I am struggling with the following:

I am building a website with basic CMS functionality.
My problem is that in one of the pages I am using Easyslider to display 
small comments about the clients.


These comments are divided in 3 per slide.
ex:(li
pcomment 1/p
pcomment 1/p
pcomment 1/p
/li)

Now I am struggling with the following:
I am pulling the comments from the db and I would like to know if i can 
split that array in 3's (array_slice) perhaps?


My goal is to within a foreach loop output 3 comments within a 
slide(wrapped in li), so first 3 would output:


(li
pcomment 1/p
pcomment 2/p
pcomment 3/p
/li)
Then another 3

(li
pcomment 4/p
pcomment 5/p
pcomment 6/p
/li)
Thank in advance for all the replies.
Paulo carvalho

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



Re: [PHP] PHP Question

2010-10-28 Thread Kevin Kinsey

Paulo Work wrote:

Hello, Paulo!


I am building a website with basic CMS functionality.
My problem is that in one of the pages I am using Easyslider to display 
small comments about the clients.


These comments are divided in 3 per slide.
ex:(li
pcomment 1/p
pcomment 1/p
pcomment 1/p
/li)

I am pulling the comments from the db and I would like to know if i can 
split that array in 3's (array_slice) perhaps?


My goal is to within a foreach loop output 3 comments within a 
slide(wrapped in li), so first 3 would output:


(li
pcomment 1/p
pcomment 2/p
pcomment 3/p
/li)
Then another 3


I'm a hacker, so this is a HACK:

?php

$data=(li
pcomment 1/p
pcomment 2/p
pcomment 3/p
/li);

$lines=explode(\n,$data);
array_shift($lines);
array_pop($lines);
print_r($lines);

?

I'll leave it to the big boys to debate and devise more elegant
solutions.

Kevin Kinsey

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



Re: [PHP] PHP Question

2010-10-28 Thread Jim Lucas
Paulo Work wrote:
 Hello my name is Paulo Carvalho and I am struggling with the following:
 
 I am building a website with basic CMS functionality.
 My problem is that in one of the pages I am using Easyslider to display
 small comments about the clients.
 
 These comments are divided in 3 per slide.
 ex:(li
 pcomment 1/p
 pcomment 1/p
 pcomment 1/p
 /li)
 
 Now I am struggling with the following:
 I am pulling the comments from the db and I would like to know if i can
 split that array in 3's (array_slice) perhaps?
 
 My goal is to within a foreach loop output 3 comments within a
 slide(wrapped in li), so first 3 would output:
 
 (li
 pcomment 1/p
 pcomment 2/p
 pcomment 3/p
 /li)
 Then another 3
 
 (li
 pcomment 4/p
 pcomment 5/p
 pcomment 6/p
 /li)
 Thank in advance for all the replies.
 Paulo carvalho
 

This looks like a job for modulo man.

I was hoping to simply give you a list of examples from google, but I couldn't
find any that showed exactly what you were trying to do, so... I wrote this
article for my site.  Let me know if you have any questions.

http://www.bendsource.com/phpModulo


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



RE: [PHP] RegExp question: how to add a number?

2010-10-15 Thread Ford, Mike
 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org]
 Sent: 14 October 2010 21:42
 
 Hi everyone,
 I hope you're doing well (haven't written here for a long time :-)).
 The question is as follows: I have a regexp that would do the
 following. If the string begins with Re:, it will change the
 beginning to Re[2]:; if it doesn't, then it would add Re: at the
 beginning. But (attention, here it is!) if the string starts with
 something like Re[4]:, it should replace it by Re[5]:.
 Here's the code:
 
 $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
 if ($start==re:) {
 $subject=preg_replace(/^re:(.+?)$/usi, re[2]:$1, $f['Subject']);
 } elseif ($start==re[) {
 // Here $1+1 doesn't work, it returns Re[4+1]:!
 $subject=preg_replace(/^re\[(\d+)\]:(.+?)$/usi, re[$1+1]:$2,
 $f['Subject']);
 } else {
 $subject=Re: .$f['Subject'];
 }
 
 I know there actually exists a way to do the numeral addition
 (Re[5]:, not Re[4+1]:).
 How do I manage to do this?

This looks like a job for the e modifier (see 
http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example #4 
at http://php.net/preg_replace). Something like:

  $subject = preg_replace(/^re\[(\d+)\:](.+?)$/eusi, 're['.(\\1+1).']:\\2', 
$f['Subject']);

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507 City Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] RegExp question: how to add a number?

2010-10-15 Thread Richard Quadling
On 15 October 2010 10:16, Ford, Mike m.f...@leedsmet.ac.uk wrote:
 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org]
 Sent: 14 October 2010 21:42

 Hi everyone,
 I hope you're doing well (haven't written here for a long time :-)).
 The question is as follows: I have a regexp that would do the
 following. If the string begins with Re:, it will change the
 beginning to Re[2]:; if it doesn't, then it would add Re: at the
 beginning. But (attention, here it is!) if the string starts with
 something like Re[4]:, it should replace it by Re[5]:.
 Here's the code:

 $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
 if ($start==re:) {
 $subject=preg_replace(/^re:(.+?)$/usi, re[2]:$1, $f['Subject']);
 } elseif ($start==re[) {
 // Here $1+1 doesn't work, it returns Re[4+1]:!
 $subject=preg_replace(/^re\[(\d+)\]:(.+?)$/usi, re[$1+1]:$2,
 $f['Subject']);
 } else {
 $subject=Re: .$f['Subject'];
 }

 I know there actually exists a way to do the numeral addition
 (Re[5]:, not Re[4+1]:).
 How do I manage to do this?

 This looks like a job for the e modifier (see 
 http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example #4 
 at http://php.net/preg_replace). Something like:

  $subject = preg_replace(/^re\[(\d+)\:](.+?)$/eusi, 
 're['.(\\1+1).']:\\2', $f['Subject']);

 Cheers!

 Mike

Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.

The callback seems to be the only way I could get the regex to work.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] RegExp question: how to add a number?

2010-10-15 Thread Andrew Ballard
On Fri, Oct 15, 2010 at 5:52 AM, Richard Quadling rquadl...@gmail.com wrote:
 On 15 October 2010 10:16, Ford, Mike m.f...@leedsmet.ac.uk wrote:
 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org]
 Sent: 14 October 2010 21:42

 Hi everyone,
 I hope you're doing well (haven't written here for a long time :-)).
 The question is as follows: I have a regexp that would do the
 following. If the string begins with Re:, it will change the
 beginning to Re[2]:; if it doesn't, then it would add Re: at the
 beginning. But (attention, here it is!) if the string starts with
 something like Re[4]:, it should replace it by Re[5]:.
 Here's the code:

 $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
 if ($start==re:) {
 $subject=preg_replace(/^re:(.+?)$/usi, re[2]:$1, $f['Subject']);
 } elseif ($start==re[) {
 // Here $1+1 doesn't work, it returns Re[4+1]:!
 $subject=preg_replace(/^re\[(\d+)\]:(.+?)$/usi, re[$1+1]:$2,
 $f['Subject']);
 } else {
 $subject=Re: .$f['Subject'];
 }

 I know there actually exists a way to do the numeral addition
 (Re[5]:, not Re[4+1]:).
 How do I manage to do this?

 This looks like a job for the e modifier (see 
 http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example 
 #4 at http://php.net/preg_replace). Something like:

  $subject = preg_replace(/^re\[(\d+)\:](.+?)$/eusi, 
 're['.(\\1+1).']:\\2', $f['Subject']);

 Cheers!

 Mike

 Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.

 The callback seems to be the only way I could get the regex to work.


How about preg_replace_callback()?

Andrew

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



Re: [PHP] RegExp question: how to add a number?

2010-10-15 Thread Richard Quadling
On 15 October 2010 15:45, Andrew Ballard aball...@gmail.com wrote:
 On Fri, Oct 15, 2010 at 5:52 AM, Richard Quadling rquadl...@gmail.com wrote:
 On 15 October 2010 10:16, Ford, Mike m.f...@leedsmet.ac.uk wrote:
 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org]
 Sent: 14 October 2010 21:42

 Hi everyone,
 I hope you're doing well (haven't written here for a long time :-)).
 The question is as follows: I have a regexp that would do the
 following. If the string begins with Re:, it will change the
 beginning to Re[2]:; if it doesn't, then it would add Re: at the
 beginning. But (attention, here it is!) if the string starts with
 something like Re[4]:, it should replace it by Re[5]:.
 Here's the code:

 $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
 if ($start==re:) {
 $subject=preg_replace(/^re:(.+?)$/usi, re[2]:$1, $f['Subject']);
 } elseif ($start==re[) {
 // Here $1+1 doesn't work, it returns Re[4+1]:!
 $subject=preg_replace(/^re\[(\d+)\]:(.+?)$/usi, re[$1+1]:$2,
 $f['Subject']);
 } else {
 $subject=Re: .$f['Subject'];
 }

 I know there actually exists a way to do the numeral addition
 (Re[5]:, not Re[4+1]:).
 How do I manage to do this?

 This looks like a job for the e modifier (see 
 http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example 
 #4 at http://php.net/preg_replace). Something like:

  $subject = preg_replace(/^re\[(\d+)\:](.+?)$/eusi, 
 're['.(\\1+1).']:\\2', $f['Subject']);

 Cheers!

 Mike

 Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.

 The callback seems to be the only way I could get the regex to work.


 How about preg_replace_callback()?

 Andrew


Already provided an example using that : http://news.php.net/php.general/308728

It was the 'e' modifier I couldn't get to work, though I suppose, as
the code is eval'd, I should have been able to do it.

The callback just seems a LOT easier.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] RegExp question: how to add a number?

2010-10-15 Thread Andrew Ballard
On Fri, Oct 15, 2010 at 11:07 AM, Richard Quadling rquadl...@gmail.com wrote:
 On 15 October 2010 15:45, Andrew Ballard aball...@gmail.com wrote:
 On Fri, Oct 15, 2010 at 5:52 AM, Richard Quadling rquadl...@gmail.com 
 wrote:
 On 15 October 2010 10:16, Ford, Mike m.f...@leedsmet.ac.uk wrote:
 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org]
 Sent: 14 October 2010 21:42

 Hi everyone,
 I hope you're doing well (haven't written here for a long time :-)).
 The question is as follows: I have a regexp that would do the
 following. If the string begins with Re:, it will change the
 beginning to Re[2]:; if it doesn't, then it would add Re: at the
 beginning. But (attention, here it is!) if the string starts with
 something like Re[4]:, it should replace it by Re[5]:.
 Here's the code:

 $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
 if ($start==re:) {
 $subject=preg_replace(/^re:(.+?)$/usi, re[2]:$1, $f['Subject']);
 } elseif ($start==re[) {
 // Here $1+1 doesn't work, it returns Re[4+1]:!
 $subject=preg_replace(/^re\[(\d+)\]:(.+?)$/usi, re[$1+1]:$2,
 $f['Subject']);
 } else {
 $subject=Re: .$f['Subject'];
 }

 I know there actually exists a way to do the numeral addition
 (Re[5]:, not Re[4+1]:).
 How do I manage to do this?

 This looks like a job for the e modifier (see 
 http://php.net/manual/en/reference.pcre.pattern.modifiers.php, and example 
 #4 at http://php.net/preg_replace). Something like:

  $subject = preg_replace(/^re\[(\d+)\:](.+?)$/eusi, 
 're['.(\\1+1).']:\\2', $f['Subject']);

 Cheers!

 Mike

 Watch out for the missing '[1]'. This needs to become '[2]' and not '[1]'.

 The callback seems to be the only way I could get the regex to work.


 How about preg_replace_callback()?

 Andrew


 Already provided an example using that : 
 http://news.php.net/php.general/308728

 It was the 'e' modifier I couldn't get to work, though I suppose, as
 the code is eval'd, I should have been able to do it.

 The callback just seems a LOT easier.


Sorry - I missed the callback function in there. The loop threw me off
because I thought that was part of the solution rather than a test
container.

Andrew

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



[PHP] RegExp question: how to add a number?

2010-10-14 Thread Andre Polykanine
Hi everyone,
I hope you're doing well (haven't written here for a long time :-)).
The question is as follows: I have a regexp that would do the
following. If the string begins with Re:, it will change the
beginning to Re[2]:; if it doesn't, then it would add Re: at the
beginning. But (attention, here it is!) if the string starts with
something like Re[4]:, it should replace it by Re[5]:.
Here's the code:

$start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
if ($start==re:) {
$subject=preg_replace(/^re:(.+?)$/usi, re[2]:$1, $f['Subject']);
} elseif ($start==re[) {
// Here $1+1 doesn't work, it returns Re[4+1]:!
$subject=preg_replace(/^re\[(\d+)\]:(.+?)$/usi, re[$1+1]:$2, $f['Subject']);
} else {
$subject=Re: .$f['Subject'];
}

I know there actually exists a way to do the numeral addition
(Re[5]:, not Re[4+1]:).
How do I manage to do this?
Thanks!

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion


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



Re: [PHP] RegExp question: how to add a number?

2010-10-14 Thread David Harkness
On Thu, Oct 14, 2010 at 1:42 PM, Andre Polykanine an...@oire.org wrote:

 But (attention, here it is!) if the string starts with
 something like Re[4]:, it should replace it by Re[5]:.


Regular expressions do not support any mathematical operations. Instead, you
need to use preg_match() to extract the number inside the brackets,
increment it, and build a new string using simple concatenation (.).

elseif ($start==re[) {
if (preg_match('/^re\[(\d+)\](.*)/i', $f['Subject'], $matches)  0)
{
$f['Subject'] = 'Re[' . ($matches[1] + 1) . ']' . $matches[2];
}
else {
// no closing brace -- now what?
}
}

David


Re: [PHP] RegExp question: how to add a number?

2010-10-14 Thread Richard Quadling
On 14 October 2010 21:42, Andre Polykanine an...@oire.org wrote:
 Hi everyone,
 I hope you're doing well (haven't written here for a long time :-)).
 The question is as follows: I have a regexp that would do the
 following. If the string begins with Re:, it will change the
 beginning to Re[2]:; if it doesn't, then it would add Re: at the
 beginning. But (attention, here it is!) if the string starts with
 something like Re[4]:, it should replace it by Re[5]:.
 Here's the code:

 $start=mb_strtolower(mb_substr($f['Subject'], 0, 3));
 if ($start==re:) {
 $subject=preg_replace(/^re:(.+?)$/usi, re[2]:$1, $f['Subject']);
 } elseif ($start==re[) {
 // Here $1+1 doesn't work, it returns Re[4+1]:!
 $subject=preg_replace(/^re\[(\d+)\]:(.+?)$/usi, re[$1+1]:$2, 
 $f['Subject']);
 } else {
 $subject=Re: .$f['Subject'];
 }

 I know there actually exists a way to do the numeral addition
 (Re[5]:, not Re[4+1]:).
 How do I manage to do this?
 Thanks!

Can you adapt this ...

?php
$s_Text = 'Re: A dummy subject.';

foreach(range(1,10) as $i_Test)
{
echo $s_Text = preg_replace_callback
(
'`^Re(\[(\d++)\])?:`',
function($a_Match)
{
if (count($a_Match) == 1)
{
$i_Count = 2;
}
else
{
$i_Count = 1 + $a_Match[2];
}
return Re[$i_Count]:;
},
$s_Text
), PHP_EOL;
}


Outputs ...

Re[2]: A dummy subject.
Re[3]: A dummy subject.
Re[4]: A dummy subject.
Re[5]: A dummy subject.
Re[6]: A dummy subject.
Re[7]: A dummy subject.
Re[8]: A dummy subject.
Re[9]: A dummy subject.
Re[10]: A dummy subject.
Re[11]: A dummy subject.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] PHP Email Question

2010-10-01 Thread kranthi
I cant see why you are getting the letter 'z' (assuming $msgContent
was referenced properly) . Complete code will be helpful to debug the
problem.

Also, Heredoc syntax will be more helpful in your situation. And usage
of global keyword is strongly discouraged in favor of $GLOBALS
superglobal array

http://php.net/GLOBALS
http://php.net/heredoc

Kranthi.
http://goo.gl/e6t3

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



Re: [PHP] PHP Email Question

2010-09-30 Thread J Ravi Menon
On Wed, Sep 29, 2010 at 1:37 PM, Joe Jackson priory...@googlemail.com wrote:
 Hi

 I am trying the following snippet as Bostjan  suggested, and an email is
 getting sent when I submit the form however in the body of the email I am
 getting none of the form data in the body of the email.  All I am getting is
 the letter 'z' ?  Also in the from field of the email this is showing as my
 email address and not the email address of the user who has sent the form

 Any ideas on where I am going wrong with this snippet?  Any advice would be
 much appreciated

 $msgContent = Name: . $values['name'] .\n;
 $msgContent .= Address: . $values['address'] .\n;
 $msgContent .= Telephone: . $values['telephone'] .\n;
 $msgContent .= Email Address: . $values['emailaddress'] .\n;
 $msgContent .= Message: . $values['message'] .\n;

 function ProcessForm($values)
 {
     mail('myemail:domain.com', 'Website Enquiry', $msgContent, From:
 \{$values['name']}\ {$values['emailaddress']});

  // Replace with actual page or redirect :P
     echo htmlheadtitleThank you!/title/headbodyThank
 you!/body/html;

Not sure if it it is a typo above, are you actually passing
$msgContent in the function above? If it is a global variable, you
would need to add a 'global' declaration:

function ProcessForm($values)
{
   global $msgContent;

mail('myemail:domain.com', 'Website Enquiry', $msgContent, From:
\{$values['name']}\ {$values['emailaddress']}\r\n);
.
.
.
}

Also try adding CRLF sequence at the end of the header line as shown above.

Ravi

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



Re: [PHP] PHP Email Question

2010-09-29 Thread Joe Jackson
Hi

I am trying the following snippet as Bostjan  suggested, and an email is
getting sent when I submit the form however in the body of the email I am
getting none of the form data in the body of the email.  All I am getting is
the letter 'z' ?  Also in the from field of the email this is showing as my
email address and not the email address of the user who has sent the form

Any ideas on where I am going wrong with this snippet?  Any advice would be
much appreciated


$msgContent = Name: . $values['name'] .\n;
$msgContent .= Address: . $values['address'] .\n;
$msgContent .= Telephone: . $values['telephone'] .\n;
$msgContent .= Email Address: . $values['emailaddress'] .\n;
$msgContent .= Message: . $values['message'] .\n;

function ProcessForm($values)
{
mail('myemail:domain.com', 'Website Enquiry', $msgContent, From:
\{$values['name']}\ {$values['emailaddress']});

 // Replace with actual page or redirect :P
echo htmlheadtitleThank you!/title/headbodyThank
you!/body/html;


Re: [PHP] Array question

2010-09-26 Thread a...@ashleysheridan.co.uk
I'd also like to add to that:

$array = array();
$array[] = 'text';
$array[2] = 123;
$array[] = 'hello';

Would output:

$array(
0 = 'text',
2 = 123,
3 = 'hello',
);

Note the missing index 1, as php makes a numerical index that is one greater 
than the highest already in use. As the index 2 was explicitly created, php 
made the next one at 3.

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

- Reply message -
From: chris h chris...@gmail.com
Date: Sat, Sep 25, 2010 22:05
Subject: [PHP] Array question
To: MikeB mpbr...@gmail.com
Cc: php-general@lists.php.net


Mike,

$results[] will automatically push a value unto the end of an array.

So doing this...
--
$magic = array();
$magic[] = 'a';
$magic[] = 'b';
$magic[] = 'c';
-

is exactly this same as doing this...
--
$normal = array();
$normal[0] = 'a';
$normal[1] = 'b';
$normal[2] = 'c';
-

And yes, in your example $results[] would be equivalent to $results[$j]


For more reference:
http://www.php.net/manual/en/language.types.array.php


Chris H.


On Sat, Sep 25, 2010 at 4:31 PM, MikeB mpbr...@gmail.com wrote:

 I have the following code:

 $query = SELECT * FROM classics;
 $result = mysql_query($query);

 if (!$result) die (Database access failed:  . mysql_error());
 $rows = mysql_num_rows($result);

 for ($j = 0 ; $j  $rows ; ++$j)
 {
$results[] = mysql_fetch_array($result);
 }

 mysql_close($db_server);

 My question, in the loop, why does tha author use:

 $results[] = mysql_fetch_array($result);

 instead of (as I would expect):

 $results[$j] = mysql_fetch_array($result);?

 What PHP magic is at work here?

 Thanks.


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




Re: [PHP] Array question

2010-09-26 Thread tedd

At 3:31 PM -0500 9/25/10, MikeB wrote:

-snip-

My question, in the loop, why does tha author use:

$results[] = mysql_fetch_array($result);

instead of (as I would expect):

$results[$j] = mysql_fetch_array($result);?

What PHP magic is at work here?


Mike:

That's just a shorthand way to populate an array in PHP.

One of the reasons for this feature is that somewhere in your code 
you may not know what the next index should be. So, if you use --


$results[] = $next_item;

-- then the $next_item will be automagically added to the next 
available index in the array. So you may be right in calling it PHP 
magic because I have not seen this in other languages.


Understand?

Cheers,

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

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



[PHP] Array question

2010-09-25 Thread MikeB

I have the following code:

$query = SELECT * FROM classics;
$result = mysql_query($query);

if (!$result) die (Database access failed:  . mysql_error());
$rows = mysql_num_rows($result);

for ($j = 0 ; $j  $rows ; ++$j)
{
$results[] = mysql_fetch_array($result);
}

mysql_close($db_server);

My question, in the loop, why does tha author use:

$results[] = mysql_fetch_array($result);

instead of (as I would expect):

$results[$j] = mysql_fetch_array($result);?

What PHP magic is at work here?

Thanks.


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



Re: [PHP] Array question

2010-09-25 Thread chris h
Mike,

$results[] will automatically push a value unto the end of an array.

So doing this...
--
$magic = array();
$magic[] = 'a';
$magic[] = 'b';
$magic[] = 'c';
-

is exactly this same as doing this...
--
$normal = array();
$normal[0] = 'a';
$normal[1] = 'b';
$normal[2] = 'c';
-

And yes, in your example $results[] would be equivalent to $results[$j]


For more reference:
http://www.php.net/manual/en/language.types.array.php


Chris H.


On Sat, Sep 25, 2010 at 4:31 PM, MikeB mpbr...@gmail.com wrote:

 I have the following code:

 $query = SELECT * FROM classics;
 $result = mysql_query($query);

 if (!$result) die (Database access failed:  . mysql_error());
 $rows = mysql_num_rows($result);

 for ($j = 0 ; $j  $rows ; ++$j)
 {
$results[] = mysql_fetch_array($result);
 }

 mysql_close($db_server);

 My question, in the loop, why does tha author use:

 $results[] = mysql_fetch_array($result);

 instead of (as I would expect):

 $results[$j] = mysql_fetch_array($result);?

 What PHP magic is at work here?

 Thanks.


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




Re: [PHP] PHP Email Question

2010-09-21 Thread J Ravi Menon
Just on this topic, I found swiftmailer library to be really useful
esp. in dealing with 'template' emails with custom variables per
recipient:

http://swiftmailer.org/

The e.g. on email template processing:

http://swiftmailer.org/docs/decorator-plugin-howto

There are batchSend() functionalities, ability to compose various mime
type emails etc...

Ravi

On Mon, Sep 20, 2010 at 8:20 AM, chris h chris...@gmail.com wrote:
 Ignore the other parameters unless you are very familiar with RFCs 2821,
 2822 and their associated RFCs



 I would advise against ignoring the other parameters.  Doing so will pretty
 much guarantee having your email end up in SPAM.  Instead look up the
 examples in the docs, or better yet use something like phpmailer as Tom
 suggested.


 Chris.


 On Sun, Sep 19, 2010 at 6:37 PM, TR Shaw ts...@oitc.com wrote:


 On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote:

  Hi
 
  Sorry for the simple question but I am trying to get my head around PHP.
  I
  have a sample PHP script that I am trying to use to send a php powered
 email
  message.  The snippet of code is shown below
 
     mail('em...@address.com', 'Subject', $values['message'], From:
  \{$values['name']}\ {$values['emailaddress']});
 
  This works fine, but how can I add in other fields to the email that is
  recieved?
 
  For example in the form there are fields called, 'emailaddress',
  'telephone', 'address' and 'name' which I need to add into the form along
  with the message field
 
  Also with the formatting how can I change the format of the email to
 
  Name: $values['name'],
  Address: etc
  Message:
 

 Joe

 The mail command lets you send mail (an RFC2821 envelop). The function is:

 bool mail ( string $to , string $subject , string $message [, string
 $additional_headers [, string$additional_parameters ]] )

 $to is where you want it to go
 $subject is whatever you want the subject to be
 $message is the information you want to send

 Ignore the other parameters unless you are very familiar with RFCs 2821,
 2822 and their associated RFCs


 So if you want to send info from a form you might want to roll it up in xml
 and send it via the message part. when you receive it you can easily decode
 it. If you don't want to do that put it in a format that you can easily
 decode on the receiving end.

 Basically mail is a way to deliver information in the $message body. How
 you format the information there is up to you. However, depending on your
 system's config you are probably constrained to placing only 7bit ascii in
 the $message body.

 You might also move away from the mail function and look at phpmailer at
 sf.net if you need more complex capabilities.

 Tom






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



[PHP] PHP Email Question

2010-09-19 Thread Joe Jackson
Hi

Sorry for the simple question but I am trying to get my head around PHP.  I
have a sample PHP script that I am trying to use to send a php powered email
message.  The snippet of code is shown below

mail('em...@address.com', 'Subject', $values['message'], From:
\{$values['name']}\ {$values['emailaddress']});

This works fine, but how can I add in other fields to the email that is
recieved?

For example in the form there are fields called, 'emailaddress',
'telephone', 'address' and 'name' which I need to add into the form along
with the message field

Also with the formatting how can I change the format of the email to

Name: $values['name'],
Address: etc
Message:

TIA


Re: [PHP] PHP Email Question

2010-09-19 Thread Bostjan Skufca
You should format the email message content first, like this:
$msgContent = Name: . $values['name'] .\n;
$msgContent .= Address: . $values['address'] .\n;

Then you should send a this content, like this:
mail('em...@address.com', 'Subject', $msgContent, From...);

b.


On 20 September 2010 00:00, Joe Jackson priory...@googlemail.com wrote:
 Hi

 Sorry for the simple question but I am trying to get my head around PHP.  I
 have a sample PHP script that I am trying to use to send a php powered email
 message.  The snippet of code is shown below

    mail('em...@address.com', 'Subject', $values['message'], From:
 \{$values['name']}\ {$values['emailaddress']});

 This works fine, but how can I add in other fields to the email that is
 recieved?

 For example in the form there are fields called, 'emailaddress',
 'telephone', 'address' and 'name' which I need to add into the form along
 with the message field

 Also with the formatting how can I change the format of the email to

 Name: $values['name'],
 Address: etc
 Message:

 TIA


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



Re: [PHP] PHP Email Question

2010-09-19 Thread TR Shaw

On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote:

 Hi
 
 Sorry for the simple question but I am trying to get my head around PHP.  I
 have a sample PHP script that I am trying to use to send a php powered email
 message.  The snippet of code is shown below
 
mail('em...@address.com', 'Subject', $values['message'], From:
 \{$values['name']}\ {$values['emailaddress']});
 
 This works fine, but how can I add in other fields to the email that is
 recieved?
 
 For example in the form there are fields called, 'emailaddress',
 'telephone', 'address' and 'name' which I need to add into the form along
 with the message field
 
 Also with the formatting how can I change the format of the email to
 
 Name: $values['name'],
 Address: etc
 Message:
 

Joe

The mail command lets you send mail (an RFC2821 envelop). The function is:

bool mail ( string $to , string $subject , string $message [, string 
$additional_headers [, string$additional_parameters ]] )

$to is where you want it to go
$subject is whatever you want the subject to be
$message is the information you want to send
Ignore the other parameters unless you are very familiar with RFCs 2821, 2822 
and their associated RFCs

So if you want to send info from a form you might want to roll it up in xml and 
send it via the message part. when you receive it you can easily decode it. If 
you don't want to do that put it in a format that you can easily decode on the 
receiving end.

Basically mail is a way to deliver information in the $message body. How you 
format the information there is up to you. However, depending on your system's 
config you are probably constrained to placing only 7bit ascii in the $message 
body.

You might also move away from the mail function and look at phpmailer at sf.net 
if you need more complex capabilities.

Tom





[PHP] Re: Question about news.php.net

2010-09-16 Thread MikeB

MikeB wrote:

Daniel Brown wrote:

On Mon, Sep 13, 2010 at 19:51, MikeBmpbr...@gmail.com wrote:


As part of the bug report I included a link to an image of my nntp
config.


I saw that, thanks. I'll look into creating a mirror of the news
server, as well, for NNTP-only access. I won't lie and say that it's
a priority, but I'll try to get to it as soon as I have time, Mike.


You must have already done something. It's working a lot better today.

Thanks.



Perhaps I spoke too soon. It seems intermittent. Lots of denials today. 
However, I've switched to the gmane list as recommended by somone else 
on this thread and that works a treat, so I may just do an unsubscribe 
here to get rid of the annoying timeout messages.



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



[PHP] Re: Question about news.php.net

2010-09-15 Thread MikeB

Gary wrote:

MikeB wrote:

I understand that the news server is based on a mailing list, but I
can't handle another high-volume source dumping stuff into my email
(even if I filter it into a separate folder) so I am trying to subscribe
through the news group.

However, getting access seems to be hit-and-miss, since I more often
than not get a message that the connection to news.php.net timed out.


Tried nntp://news.gmane.org/gmane.comp.php.general ?


Bingo!  Thanks!


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



Re: [PHP] php cli question

2010-09-15 Thread Bostjan Skufca
Here are the results I got when question of migration from apache to nginx
was brought up:
http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/
(BTW there is some FPM in main PHP distribution now)

As for resource management, I recommend looking at php sources
(Zend/zend_alloca.c:zend_mm_shutdown() specifically) and building a custom
extension that frees discarded memory resources on your request or timer or
sth else. Not sure if it is possible like that but this is just a
suggestion, don't quote me on that :)
Also, for such questions I recommend you to join php-internals mailing list,
it seems more appropriate.

b.


On 15 September 2010 04:19, J Ravi Menon jravime...@gmail.com wrote:

 On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  Few questions:
 
  1) Does opcode cache really matter in such cli-based daemons? As
  'SomeClass' is instantiated at every loop, I am assuming it is only
  compiled once as it has already been 'seen'.
 
  Yup.
 
  Just to clarify, you mean we don't need the op-code cache here right?
 
  That is correct.
 
  2) What about garbage collection? In a standard apache-mod-php
  setup, we rely on the end of a request-cycle to free up resources -
  close file descriptiors, free up memory etc..
  I am assuming in the aforesaid standalone daemon case, we would
  have to do this manually?
 
  Yes.
 
  So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
  right way to go for non-resource based items? i.e. it needs to be
  explicitly done?
 
  It's not quite like C - if you reassign something, the previous contents
  are automagically freed.  I use unset() if I know it could be a while
  (hours) before it'll likely be reassigned, but it won't be used in the
  meantime.
 

 Thanks Per for clarifying this for me. Now on my follow up question:

 [Note: I think it is related to the issues discussed above hence
 keeping it on this thread but if I am violating any guidelines here,
 do let me know]

 One reason the aforesaid questions got triggered was that in our
 company right now, there is a big discussion on moving away from
 apache+mod_php solution to nginx+fast-cgi based model for handling all
 php-based services. The move seems to be more based some anecdotal
 observations and possibly not based on a typical php-based app (i.e.
 the php script involved was trivial one acting as some proxy to
 another backend service).

 I have written fast-cgi servers in the past in C++, and I am aware how
 the apahcefast-cgi-servers work (in unix socket setups).  All
 our php apps are written with apache+mod_php in mind (no explicit
 resource mgmt ), so this was a concern to me.

 If the same scripts now need to run 'forever' as a fastcgi server, are
 we forced to do such manual resource mgmt? Or are there solutions here
 that work just as in mod_php?

 This reminded me of the cli daemons that I had written earlier where
 such manual cleanups were done, and hence my doubts on this
 nginx+fast-cgi approach.

 thx,
 Ravi


 
 
  --
  Per Jessen, Zürich (14.6°C)
 
 
  --
  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] php cli question

2010-09-15 Thread J Ravi Menon
Thanks Bostjan for the suggestion. I did raise the issue and here is the reply:

http://news.php.net/php.internals/49672

Thx,
Ravi


On Wed, Sep 15, 2010 at 2:38 AM, Bostjan Skufca bost...@a2o.si wrote:
 Here are the results I got when question of migration from apache to nginx
 was brought up:
 http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/
 (BTW there is some FPM in main PHP distribution now)

 As for resource management, I recommend looking at php sources
 (Zend/zend_alloca.c:zend_mm_shutdown() specifically) and building a custom
 extension that frees discarded memory resources on your request or timer or
 sth else. Not sure if it is possible like that but this is just a
 suggestion, don't quote me on that :)
 Also, for such questions I recommend you to join php-internals mailing list,
 it seems more appropriate.

 b.


 On 15 September 2010 04:19, J Ravi Menon jravime...@gmail.com wrote:

 On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  Few questions:
 
  1) Does opcode cache really matter in such cli-based daemons? As
  'SomeClass' is instantiated at every loop, I am assuming it is only
  compiled once as it has already been 'seen'.
 
  Yup.
 
  Just to clarify, you mean we don't need the op-code cache here right?
 
  That is correct.
 
  2) What about garbage collection? In a standard apache-mod-php
  setup, we rely on the end of a request-cycle to free up resources -
  close file descriptiors, free up memory etc..
  I am assuming in the aforesaid standalone daemon case, we would
  have to do this manually?
 
  Yes.
 
  So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
  right way to go for non-resource based items? i.e. it needs to be
  explicitly done?
 
  It's not quite like C - if you reassign something, the previous contents
  are automagically freed.  I use unset() if I know it could be a while
  (hours) before it'll likely be reassigned, but it won't be used in the
  meantime.
 

 Thanks Per for clarifying this for me. Now on my follow up question:

 [Note: I think it is related to the issues discussed above hence
 keeping it on this thread but if I am violating any guidelines here,
 do let me know]

 One reason the aforesaid questions got triggered was that in our
 company right now, there is a big discussion on moving away from
 apache+mod_php solution to nginx+fast-cgi based model for handling all
 php-based services. The move seems to be more based some anecdotal
 observations and possibly not based on a typical php-based app (i.e.
 the php script involved was trivial one acting as some proxy to
 another backend service).

 I have written fast-cgi servers in the past in C++, and I am aware how
 the apahcefast-cgi-servers work (in unix socket setups).  All
 our php apps are written with apache+mod_php in mind (no explicit
 resource mgmt ), so this was a concern to me.

 If the same scripts now need to run 'forever' as a fastcgi server, are
 we forced to do such manual resource mgmt? Or are there solutions here
 that work just as in mod_php?

 This reminded me of the cli daemons that I had written earlier where
 such manual cleanups were done, and hence my doubts on this
 nginx+fast-cgi approach.

 thx,
 Ravi


 
 
  --
  Per Jessen, Zürich (14.6°C)
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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




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



Re: [PHP] php cli question

2010-09-14 Thread Per Jessen
J Ravi Menon wrote:

 Few questions:
 
 1) Does opcode cache really matter in such cli-based daemons? As
 'SomeClass' is instantiated at every loop, I am assuming it is only
 compiled once as it has already been 'seen'.

Yup.

 2) What about garbage collection? In a standard apache-mod-php setup,
 we rely on the end of a request-cycle to free up resources - close
 file descriptiors, free up memory etc..
 I am assuming in the aforesaid standalone daemon case, we would
 have to do this manually?  

Yes.

 Note: I have written pre-forker deamons in php directly and
 successfully deployed them in the past, but never looked at in depth
 to understand all the nuances. Anecdotally, I have
 done 'unset()' at some critical places were large arrays were used,
 and I think it helped. AFAIK, unlike Java, there is no 'garbage
 collector' thread that does all the magic?

Correct.



-- 
Per Jessen, Zürich (12.9°C)


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



Re: [PHP] php cli question

2010-09-14 Thread J Ravi Menon
On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen p...@computer.org wrote:
 J Ravi Menon wrote:

 Few questions:

 1) Does opcode cache really matter in such cli-based daemons? As
 'SomeClass' is instantiated at every loop, I am assuming it is only
 compiled once as it has already been 'seen'.

 Yup.

Just to clarify, you mean we don't need the op-code cache here right?



 2) What about garbage collection? In a standard apache-mod-php setup,
 we rely on the end of a request-cycle to free up resources - close
 file descriptiors, free up memory etc..
     I am assuming in the aforesaid standalone daemon case, we would
 have to do this manually?

 Yes.


So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
right way to go for non-resource based items? i.e. it needs to be
explicitly done?

thx,
Ravi



 Note: I have written pre-forker deamons in php directly and
 successfully deployed them in the past, but never looked at in depth
 to understand all the nuances. Anecdotally, I have
 done 'unset()' at some critical places were large arrays were used,
 and I think it helped. AFAIK, unlike Java, there is no 'garbage
 collector' thread that does all the magic?

 Correct.



 --
 Per Jessen, Zürich (12.9°C)


 --
 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] php cli question

2010-09-14 Thread Per Jessen
J Ravi Menon wrote:

 On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen p...@computer.org wrote:
 J Ravi Menon wrote:

 Few questions:

 1) Does opcode cache really matter in such cli-based daemons? As
 'SomeClass' is instantiated at every loop, I am assuming it is only
 compiled once as it has already been 'seen'.

 Yup.
 
 Just to clarify, you mean we don't need the op-code cache here right?

That is correct.

 2) What about garbage collection? In a standard apache-mod-php
 setup, we rely on the end of a request-cycle to free up resources -
 close file descriptiors, free up memory etc..
 I am assuming in the aforesaid standalone daemon case, we would
 have to do this manually?

 Yes.
 
 So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
 right way to go for non-resource based items? i.e. it needs to be
 explicitly done?

It's not quite like C - if you reassign something, the previous contents
are automagically freed.  I use unset() if I know it could be a while
(hours) before it'll likely be reassigned, but it won't be used in the
meantime. 



-- 
Per Jessen, Zürich (14.6°C)


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



[PHP] Image question for runways

2010-09-14 Thread Alexis

Hi,

I am trying to create an on the fly image of runway layouts but am 
hitting a brick wall.


I have both the starting and ending coordinates of each runway, it's 
length, as well as it's angle of direction (heading).


I can draw one runway without any problem, but where I am falling short 
is how to 'scale', if that is the right word, the other runway(s) to 
display properly in a 500x500px image



function imagepolarline($image,$x1,$y1,$length,$angle,$color)
{
$length=($length/500)*20;
$x2 = $x1 + cos( deg2rad($angle-90)) * $length;
$y2 = $y1 + sin( deg2rad($angle-90)) * $length;
imageline($image, $x1,$y1,$x2,$y2, $color); 
}

//'base' coords
$x1=200;$y1=200;

$scale=1;

//if first runway
if ($d==0) {$xbase=abs($lon1);$ybase=abs($lat1);}
//for all others
else
{
$x1=$x1+(($xbase-(abs($lon1)))*$scale);
$y1=$y1+(($ybase-(abs($lat1)))*$scale);
}


Here is some test data if that would help:
length,lat_start,lon_start,heading,lat_stop,lon_stop
6869,38.8424,-77.0368,355.5000,38.8612,-77.0387
4911,38.8423,-77.0408,26.,38.8544,-77.0333
5204,38.8617,-77.0438,142.7000,38.8503,-77.0327

Any suggestions would be most appreciated.

Alexis

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



Re: [PHP] php cli question

2010-09-14 Thread Nathan Rixham

Per Jessen wrote:

J Ravi Menon wrote:

2) What about garbage collection? In a standard apache-mod-php
setup, we rely on the end of a request-cycle to free up resources -
close file descriptiors, free up memory etc..
I am assuming in the aforesaid standalone daemon case, we would
have to do this manually?

Yes.

So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
right way to go for non-resource based items? i.e. it needs to be
explicitly done?


It's not quite like C - if you reassign something, the previous contents
are automagically freed.  I use unset() if I know it could be a while
(hours) before it'll likely be reassigned, but it won't be used in the
meantime. 


Has anybody done a comparison of setting to null rather than unset'ing; 
does unset invoke the garbage collector instantly? i.e. is unset the 
best approach to clearing objects from memory quickly?


Best,

Nathan

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



Re: [PHP] php cli question

2010-09-14 Thread J Ravi Menon
On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen p...@computer.org wrote:
 J Ravi Menon wrote:

 On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen p...@computer.org wrote:
 J Ravi Menon wrote:

 Few questions:

 1) Does opcode cache really matter in such cli-based daemons? As
 'SomeClass' is instantiated at every loop, I am assuming it is only
 compiled once as it has already been 'seen'.

 Yup.

 Just to clarify, you mean we don't need the op-code cache here right?

 That is correct.

 2) What about garbage collection? In a standard apache-mod-php
 setup, we rely on the end of a request-cycle to free up resources -
 close file descriptiors, free up memory etc..
 I am assuming in the aforesaid standalone daemon case, we would
 have to do this manually?

 Yes.

 So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
 right way to go for non-resource based items? i.e. it needs to be
 explicitly done?

 It's not quite like C - if you reassign something, the previous contents
 are automagically freed.  I use unset() if I know it could be a while
 (hours) before it'll likely be reassigned, but it won't be used in the
 meantime.


Thanks Per for clarifying this for me. Now on my follow up question:

[Note: I think it is related to the issues discussed above hence
keeping it on this thread but if I am violating any guidelines here,
do let me know]

One reason the aforesaid questions got triggered was that in our
company right now, there is a big discussion on moving away from
apache+mod_php solution to nginx+fast-cgi based model for handling all
php-based services. The move seems to be more based some anecdotal
observations and possibly not based on a typical php-based app (i.e.
the php script involved was trivial one acting as some proxy to
another backend service).

I have written fast-cgi servers in the past in C++, and I am aware how
the apahcefast-cgi-servers work (in unix socket setups).  All
our php apps are written with apache+mod_php in mind (no explicit
resource mgmt ), so this was a concern to me.

If the same scripts now need to run 'forever' as a fastcgi server, are
we forced to do such manual resource mgmt? Or are there solutions here
that work just as in mod_php?

This reminded me of the cli daemons that I had written earlier where
such manual cleanups were done, and hence my doubts on this
nginx+fast-cgi approach.

thx,
Ravi




 --
 Per Jessen, Zürich (14.6°C)


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



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



[PHP] Re: php cli question

2010-09-13 Thread J Ravi Menon
On Sat, Sep 11, 2010 at 8:50 PM, Shawn McKenzie nos...@mckenzies.net wrote:
 On 09/10/2010 11:13 AM, J Ravi Menon wrote:
 Hi,

 I have some basic questions on running php  (5.2.x series on Linux
 2.6) as a standalone daemon using posix methods (fork() etc..):

 #!/usr/bin/php
 ?php

 require_once ('someclass.php');

 // do some initializations
 .

 // main 'forever' loop - the '$shutdown'  will
 // be set to true via a signal handler

 while(!$shutdown)
 {
   $a = new SomeClass();

   $a-doSomething()

 }

 // shutdown logic.

 The 'someclass.php' in turn will include other files (via require_once).

 The above file will be executed directly from the shell. The main loop
 could be listening to new requests via sockets etc..

 Few questions:

 1) Does opcode cache really matter in such cli-based daemons? As
 'SomeClass' is instantiated at every loop, I am assuming it is only
 compiled once as it has already been 'seen'.
     I am not very clear on how apc (or eaccelerator) works in such cases.


 2) What about garbage collection? In a standard apache-mod-php setup,
 we rely on the end of a request-cycle to free up resources - close
 file descriptiors, free up memory etc..
     I am assuming in the aforesaid standalone daemon case, we would
 have to do this manually?  In the loop above, would it be better to
 'unset($a)' explicitly at the end of it before
     it goes to the next iteration?

 Note: I have written pre-forker deamons in php directly and
 successfully deployed them in the past, but never looked at in depth
 to understand all the nuances. Anecdotally, I have
 done 'unset()' at some critical places were large arrays were used,
 and I think it helped. AFAIK, unlike Java, there is no 'garbage
 collector' thread that does all the magic?

 Thanks,
 Ravi

 If I have time when you reply I'll answer the questions, but I must ask:
  Is this purely academic?  Why is this a concern?  Have you encountered
 issues?  If so, what?

@Tom: I have compiled php with pcntl on and this has never been an
issue. It works well (on a linux setup), and I have deployed
standalone daemons with out any major problems. I have a home-grown
'preforker' framework (which I hope to share soon) which can be used
to exploit multi-core boxes.

@Shawn: It is not academic. There is a follow-up I am planning based
on the doubts above. I have deployed such daemons in the past with
some assumptions on (2) by doing manual cleanups - e.g. closing curl
connections, closing up db handles etc...  Really want to understand
how php works in such setups outside of apache+mod_php.

thanks,
Ravi








 --
 Thanks!
 -Shawn
 http://www.spidean.com


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



[PHP] Re: php cli question

2010-09-11 Thread Shawn McKenzie
On 09/10/2010 11:13 AM, J Ravi Menon wrote:
 Hi,
 
 I have some basic questions on running php  (5.2.x series on Linux
 2.6) as a standalone daemon using posix methods (fork() etc..):
 
 #!/usr/bin/php
 ?php
 
 require_once ('someclass.php');
 
 // do some initializations
 .
 
 // main 'forever' loop - the '$shutdown'  will
 // be set to true via a signal handler
 
 while(!$shutdown)
 {
   $a = new SomeClass();
 
   $a-doSomething()
 
 }
 
 // shutdown logic.
 
 The 'someclass.php' in turn will include other files (via require_once).
 
 The above file will be executed directly from the shell. The main loop
 could be listening to new requests via sockets etc..
 
 Few questions:
 
 1) Does opcode cache really matter in such cli-based daemons? As
 'SomeClass' is instantiated at every loop, I am assuming it is only
 compiled once as it has already been 'seen'.
 I am not very clear on how apc (or eaccelerator) works in such cases.
 
 
 2) What about garbage collection? In a standard apache-mod-php setup,
 we rely on the end of a request-cycle to free up resources - close
 file descriptiors, free up memory etc..
 I am assuming in the aforesaid standalone daemon case, we would
 have to do this manually?  In the loop above, would it be better to
 'unset($a)' explicitly at the end of it before
 it goes to the next iteration?
 
 Note: I have written pre-forker deamons in php directly and
 successfully deployed them in the past, but never looked at in depth
 to understand all the nuances. Anecdotally, I have
 done 'unset()' at some critical places were large arrays were used,
 and I think it helped. AFAIK, unlike Java, there is no 'garbage
 collector' thread that does all the magic?
 
 Thanks,
 Ravi

If I have time when you reply I'll answer the questions, but I must ask:
 Is this purely academic?  Why is this a concern?  Have you encountered
issues?  If so, what?

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] newbie question about code

2010-09-10 Thread Adam Williams
I'm looking at someone's code to learn and I'm relatively new to 
programming.  In the code I see commands like:


$code-do_command();

I'm not really sure what that means.  How would that look in procedural 
style programming?  do_command($code); or something else?



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



RE: [PHP] newbie question about code

2010-09-10 Thread Bob McConnell
Did you mean to say That is a method call.?

Bob McConnell

-
From: Joshua Kehn

That is a function call. In Java:

class Code
{
public static void function do_command(){ }
}

Code.do_command();

Regards,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com

On Sep 10, 2010, at 2:27 PM, Adam Williams wrote:

 I'm looking at someone's code to learn and I'm relatively new to
programming.  In the code I see commands like:
 
 $code-do_command();
 
 I'm not really sure what that means.  How would that look in
procedural style programming?  do_command($code); or something else?
 

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



Re: [PHP] newbie question about code

2010-09-10 Thread Joshua Kehn
Bob-

Yes, yes I did.

And note that my Java code is incorrect, that should simply be public static 
void, no function.

This is what I get for taking a week to code everything in Node.js. 

Regards,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com

On Sep 10, 2010, at 2:32 PM, Bob McConnell wrote:

 Did you mean to say That is a method call.?
 
 Bob McConnell
 
 -
 From: Joshua Kehn
 
 That is a function call. In Java:
 
 class Code
 {
public static void function do_command(){ }
 }
 
 Code.do_command();
 
 Regards,
 
 -Josh
 
 Joshua Kehn | josh.k...@gmail.com
 http://joshuakehn.com
 
 On Sep 10, 2010, at 2:27 PM, Adam Williams wrote:
 
 I'm looking at someone's code to learn and I'm relatively new to
 programming.  In the code I see commands like:
 
 $code-do_command();
 
 I'm not really sure what that means.  How would that look in
 procedural style programming?  do_command($code); or something else?
 


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



Re: [PHP] newbie question about code

2010-09-10 Thread a...@ashleysheridan.co.uk
It's object oriented code. $code is an instance of class, and do_command() is a 
method if that class. I'd advise reading up on oop php.

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

- Reply message -
From: Adam Williams adam_willi...@bellsouth.net
Date: Fri, Sep 10, 2010 19:27
Subject: [PHP] newbie question about code
To: PHP General list php-general@lists.php.net

I'm looking at someone's code to learn and I'm relatively new to 
programming.  In the code I see commands like:

$code-do_command();

I'm not really sure what that means.  How would that look in procedural 
style programming?  do_command($code); or something else?


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



Re: [PHP] newbie question about code

2010-09-10 Thread a...@ashleysheridan.co.uk
Node.js, wouldn't that be javascript rather than java?  :P

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

- Reply message -
From: Joshua Kehn josh.k...@gmail.com
Date: Fri, Sep 10, 2010 19:32
Subject: [PHP] newbie question about code
To: Bob McConnell r...@cbord.com
Cc: Adam Williams adam_willi...@bellsouth.net, PHP General list 
php-general@lists.php.net


Bob-

Yes, yes I did.

And note that my Java code is incorrect, that should simply be public static 
void, no function.

This is what I get for taking a week to code everything in Node.js. 

Regards,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com

On Sep 10, 2010, at 2:32 PM, Bob McConnell wrote:

 Did you mean to say That is a method call.?
 
 Bob McConnell
 
 -
 From: Joshua Kehn
 
 That is a function call. In Java:
 
 class Code
 {
public static void function do_command(){ }
 }
 
 Code.do_command();
 
 Regards,
 
 -Josh
 
 Joshua Kehn | josh.k...@gmail.com
 http://joshuakehn.com
 
 On Sep 10, 2010, at 2:27 PM, Adam Williams wrote:
 
 I'm looking at someone's code to learn and I'm relatively new to
 programming.  In the code I see commands like:
 
 $code-do_command();
 
 I'm not really sure what that means.  How would that look in
 procedural style programming?  do_command($code); or something else?
 


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



Re: [PHP] newbie question about code

2010-09-10 Thread Joshua Kehn
Ash-

Correct, hence my typo and nomenclature slip. ;)

Regards,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com

On Sep 10, 2010, at 2:48 PM, a...@ashleysheridan.co.uk wrote:

 Node.js, wouldn't that be javascript rather than java?  :P
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 - Reply message -
 From: Joshua Kehn josh.k...@gmail.com
 Date: Fri, Sep 10, 2010 19:32
 Subject: [PHP] newbie question about code
 To: Bob McConnell r...@cbord.com
 Cc: Adam Williams adam_willi...@bellsouth.net, PHP General list 
 php-general@lists.php.net
 
 
 Bob-
 
 Yes, yes I did.
 
 And note that my Java code is incorrect, that should simply be public static 
 void, no function.
 
 This is what I get for taking a week to code everything in Node.js. 
 
 Regards,
 
 -Josh
 
 Joshua Kehn | josh.k...@gmail.com
 http://joshuakehn.com
 
 On Sep 10, 2010, at 2:32 PM, Bob McConnell wrote:
 
  Did you mean to say That is a method call.?
  
  Bob McConnell
  
  -
  From: Joshua Kehn
  
  That is a function call. In Java:
  
  class Code
  {
 public static void function do_command(){ }
  }
  
  Code.do_command();
  
  Regards,
  
  -Josh
  
  Joshua Kehn | josh.k...@gmail.com
  http://joshuakehn.com
  
  On Sep 10, 2010, at 2:27 PM, Adam Williams wrote:
  
  I'm looking at someone's code to learn and I'm relatively new to
  programming.  In the code I see commands like:
  
  $code-do_command();
  
  I'm not really sure what that means.  How would that look in
  procedural style programming?  do_command($code); or something else?
  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 



Re: [PHP] newbie question about code

2010-09-10 Thread tedd

At 2:27 PM -0400 9/10/10, Joshua Kehn wrote:

Adam-

That is a function call. In Java:

class Code
{
public static void function do_command(){ }
}

Code.do_command();

Regards,

-Josh


Not just Java, but does I've seen this in several languages.

Javascript is one. But realize that Java is to Javascript as Ham is 
to Hamster. In other words, the two aren't related.


Cheers,

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

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



Re: [PHP] newbie question about code

2010-09-10 Thread Adam Richardson



 This is what I get for taking a week to code everything in Node.js.



It is a Friday, so I'll let my curiosity get the best of me and ask a
follow-up on something non-PHP.  What insights/impressions do you have
regarding Node.js after a week of working with it?

Thanks,

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] newbie question about code

2010-09-10 Thread chris h
I would check this out to give you a decent understanding of php's oop.

http://php.net/manual/en/language.oop5.php


Chris.


On Fri, Sep 10, 2010 at 2:27 PM, Adam Williams
adam_willi...@bellsouth.netwrote:

 I'm looking at someone's code to learn and I'm relatively new to
 programming.  In the code I see commands like:

 $code-do_command();

 I'm not really sure what that means.  How would that look in procedural
 style programming?  do_command($code); or something else?


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



Re: [PHP] newbie question about code

2010-09-10 Thread Joshua Kehn
Adam-

It is unique. I'm writing code that really can't be done any other way. How it 
handles events, sockets, etc is exceptional. The best part is everything now is 
JavaScript. The server (Node.js) is written in JavaScript. MongoDB is 
JavaScript. The frontend used to manage the WebSocket is entirely JavaScript. 

I have essentially replaced J2EE as the backend with Node and I couldn't be 
happier.

Of course standard JavaScript woes apply. Debugging is a royal pain in the ass. 
Your code can and will suddenly fail due to odd strange errors. There are 
stability concerns with Node, it is version 0.2 after all. 

It won't replace PHP or Java as an enterprise level solution, but it does fill 
in the gaps very nicely. 

Regards,

-Josh

Joshua Kehn | josh.k...@gmail.com
http://joshuakehn.com

On Sep 10, 2010, at 2:53 PM, Adam Richardson wrote:

 
 
 
 This is what I get for taking a week to code everything in Node.js.
 
 
 
 It is a Friday, so I'll let my curiosity get the best of me and ask a
 follow-up on something non-PHP.  What insights/impressions do you have
 regarding Node.js after a week of working with it?
 
 Thanks,
 
 Adam
 
 -- 
 Nephtali:  PHP web framework that functions beautifully
 http://nephtaliproject.com


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



Re: [PHP] newbie question about code

2010-09-10 Thread Adam Richardson
On Fri, Sep 10, 2010 at 3:03 PM, Joshua Kehn josh.k...@gmail.com wrote:

 Adam-

 It is unique. I'm writing code that really can't be done any other way. How
 it handles events, sockets, etc is exceptional. The best part is everything
 now is JavaScript. The server (Node.js) is written in JavaScript. MongoDB is
 JavaScript. The frontend used to manage the WebSocket is entirely
 JavaScript.

 I have essentially replaced J2EE as the backend with Node and I couldn't be
 happier.

 Of course standard JavaScript woes apply. Debugging is a royal pain in the
 ass. Your code can and will suddenly fail due to odd strange errors. There
 are stability concerns with Node, it is version 0.2 after all.

 It won't replace PHP or Java as an enterprise level solution, but it does
 fill in the gaps very nicely.

 Regards,

 -Josh


Thanks for the insights, Josh.

I've been intrigued by Node.js and it's architectural implications, and your
feedback helps as I evaluate potential projects/experiments going forward.
 Excellent point about the debugging relative to other environments.  Palm's
inclusion of Node.js in webOS 2.0 does help provide more confidence in the
code-base, even if it is relatively early in the development cycle, so I
guess I'll have to start tinkering soon :)

Thanks again,

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


[PHP] openssl_pkey_new question

2010-08-19 Thread tedd

Hi gang:

I'm trying to keep my questions simple.

Does the function openssl_pkey_new use 40, 56, 128, 256, or what 
bit encryption?


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] Quick Question

2010-06-15 Thread Malka Cymbalista
The address to subscribe to the javascript list is 
http://lists.evolt.org/mailman/listinfo/javascript
There is a link there to the archives.
-- 

Malka Cymbalista
Webmaster, Weizmann Institute of Science
malki.cymbali...@weizmann.ac.il
08-934-3036


 On 6/15/2010 at 12:16 AM, in message
513c9a13-7e3a-44e5-a3b3-1e15bb467...@designdrumm.com, Karl DeSaulniers
k...@designdrumm.com wrote:
 Thanks Malka,
 I was wondering if you had a web page I could go to before I sign up  
 to see some discussions that have taken place.
 I tried using the  lists.evolt.org, but it did not show the  
 javascript section.
 TIA,
 
 Karl
 
 
 On Jun 14, 2010, at 3:20 AM, Malka Cymbalista wrote:
 
 javascr...@lists.evolt.org 
 -- 

 Malka Cymbalista
 Webmaster, Weizmann Institute of Science
 malki.cymbali...@weizmann.ac.il 
 08-934-3036


 On 6/14/2010 at  2:06 AM, in message
 26040320-88f0-4cf3-84ca-2ff81891b...@designdrumm.com, Karl  
 DeSaulniers
 k...@designdrumm.com wrote:
 Hello List,
 I may have asked this before, but can not find any emails about it.
 Does anyone know of a general-javascript email list like this php  
 list?
 Hoping someone here can point me in the right direction.
 TIA

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com 

 
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com 
 


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



Re: [PHP] Quick Question

2010-06-14 Thread Karl DeSaulniers

Thanks Malka,
I was wondering if you had a web page I could go to before I sign up  
to see some discussions that have taken place.
I tried using the  lists.evolt.org, but it did not show the  
javascript section.

TIA,

Karl


On Jun 14, 2010, at 3:20 AM, Malka Cymbalista wrote:


javascr...@lists.evolt.org
--

Malka Cymbalista
Webmaster, Weizmann Institute of Science
malki.cymbali...@weizmann.ac.il
08-934-3036



On 6/14/2010 at  2:06 AM, in message
26040320-88f0-4cf3-84ca-2ff81891b...@designdrumm.com, Karl  
DeSaulniers

k...@designdrumm.com wrote:

Hello List,
I may have asked this before, but can not find any emails about it.
Does anyone know of a general-javascript email list like this php  
list?

Hoping someone here can point me in the right direction.
TIA

Karl DeSaulniers
Design Drumm
http://designdrumm.com




Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP] Quick Question

2010-06-14 Thread Karl DeSaulniers


On Jun 14, 2010, at 3:45 PM, Paul M Foster wrote:


On Sun, Jun 13, 2010 at 06:06:16PM -0500, Karl DeSaulniers wrote:


Hello List,
I may have asked this before, but can not find any emails about it.
Does anyone know of a general-javascript email list like this php  
list?

Hoping someone here can point me in the right direction.
TIA


Listen, Karl, if you find something like this, let me know. I've been
looking for a javascript list as well.

Thanks,

Paul

--
Paul M. Foster


Hi Paul,
I will post my results here when I find something.


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP] Quick Question

2010-06-13 Thread Nilesh Govindarajan
On Mon, Jun 14, 2010 at 4:36 AM, Karl DeSaulniers k...@designdrumm.com wrote:
 Hello List,
 I may have asked this before, but can not find any emails about it.
 Does anyone know of a general-javascript email list like this php list?
 Hoping someone here can point me in the right direction.
 TIA

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com




I don't know about MLs, but you can look for some user groups on
google and yahoo.

-- 
Nilesh Govindarajan
Facebook: nilesh.gr
Twitter: nileshgr
Website: www.itech7.com
Cheap and Reliable VPS Hosting: http://j.mp/arHk5e

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



Re: [PHP] NetBeans Question

2010-06-01 Thread tedd

At 2:50 AM +0100 5/31/10, Ashley Sheridan wrote:

On Mon, 2010-05-31 at 02:46 +0100, Mark Kelly wrote:

Yeah, like I mentioned earlier, Dreamweaver is known for having issues
with include files, can be slow when working on large projects with lots
of files, and is only available for Mac and Windows, which limits it
somewhat.

Thanks,
Ash



I won't address anything Brandon has to say, but as far a DW, it's 
just another bloatware WYSIWYG web-development application.


While it has a decent editor and file management system, the 
bloatware baggage as well as the price tag is more than I have keep 
up with.


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] NetBeans Question

2010-05-31 Thread Dušan Novaković
Hi, I've been using NetBeans for some time and I found that there are
some issues like for Web applications if you write html tag
incorrectlly, you wont be informed about that, for stand alone
applications in Java there were also some stupid errors, etc. So, I
strongly suggest to check out Eclipse(http://www.eclipse.org/)! You
can easily download Eclipse for PHP on Windows, Linux and MAC, and the
best part is that you can also easily find and add different plugins
like SVN, JS, etc. Just check it out... ;-)

Regards,
Dusan

On Mon, May 31, 2010 at 4:13 AM, Mark Kelly p...@wastedtimes.net wrote:
 Hi.

 On Monday 31 May 2010 at 02:50 Ashley Sheridan wrote:
 Yeah, like I mentioned earlier, Dreamweaver is known for having issues
 with include files, can be slow when working on large projects with lots
 of files, and is only available for Mac and Windows, which limits it
 somewhat.

 Indeed. I can't stand the thing myself - I was just being polite :)

 I use netbeans on Linux and Windows, so its cross-platform nature is quite
 important to me. I also appreciate the Subversion integration, which is very
 nicely done.

 Tedd: I'm no expert, but I'll chime in if I have any answers for you.

 Cheers,

 Mark

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





-- 
made by ndusan

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



Re: [PHP] NetBeans Question

2010-05-31 Thread Mario Lacunza

Hello,

what about the Netbeans ram eating?

Mario

On 31/05/10 02:03, Dušan Novaković wrote:

Hi, I've been using NetBeans for some time and I found that there are
some issues like for Web applications if you write html tag
incorrectlly, you wont be informed about that, for stand alone
applications in Java there were also some stupid errors, etc. So, I
strongly suggest to check out Eclipse(http://www.eclipse.org/)! You
can easily download Eclipse for PHP on Windows, Linux and MAC, and the
best part is that you can also easily find and add different plugins
like SVN, JS, etc. Just check it out... ;-)

Regards,
Dusan

On Mon, May 31, 2010 at 4:13 AM, Mark Kellyp...@wastedtimes.net  wrote:
   

Hi.

On Monday 31 May 2010 at 02:50 Ashley Sheridan wrote:
 

Yeah, like I mentioned earlier, Dreamweaver is known for having issues
with include files, can be slow when working on large projects with lots
of files, and is only available for Mac and Windows, which limits it
somewhat.
   

Indeed. I can't stand the thing myself - I was just being polite :)

I use netbeans on Linux and Windows, so its cross-platform nature is quite
important to me. I also appreciate the Subversion integration, which is very
nicely done.

Tedd: I'm no expert, but I'll chime in if I have any answers for you.

Cheers,

Mark

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


 



   


--

Saludos / Best regards

Mario Lacunza
Email:: mlacu...@gmail.com
Personal Website:: http://lacunza.biz/
Hosting:: http://mlv-host.com/
Google Talk: mlacunzav Skype: mlacunzav
MSN: mlacun...@hotmail.com Y! messenger: mlacunzav


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



Re: [PHP] NetBeans Question

2010-05-31 Thread Jan G.B.
Hi there.

I'm also a User of the Netbeans IDE and I can tell you the following:

 - Netbeans is the only IDE who can load very large PHP scripts (f.e.
1mb PHP Script with a multiple of 10thousands of lines) with syntax
highlighting and SUPERB code completion. It works with include files,
you can adjust RAM settings, you can work with files opened via ssh,
Subersion integration is absolutley loveley, you can connect to a
DB-Server with it to have the Schema and so on in your IDE, the
Debugging feature works like a charm and it's simply much better than
the following IDEs:

 - Zend Framework
 - Komodo Edit/ Komodo IDE
 - Eclipse
 - Kdevelop (heh - just kidding, mentioning this one)

I Use it on Linux 64 bit and it simply rocks.


@tedd: I'd just do what's obvious: Use a versioning system like
Subversion. It can work via ssh, so there's no need to open a port for
an extra daemon on any server.

Further questions may be addresses to this list, I'd say. You'll have
a more chances for an answer. ;)



Regards




2010/5/31 Mario Lacunza mlacu...@gmail.com:
 Hello,

 what about the Netbeans ram eating?

 Mario

 On 31/05/10 02:03, Dušan Novaković wrote:

 Hi, I've been using NetBeans for some time and I found that there are
 some issues like for Web applications if you write html tag
 incorrectlly, you wont be informed about that, for stand alone
 applications in Java there were also some stupid errors, etc. So, I
 strongly suggest to check out Eclipse(http://www.eclipse.org/)! You
 can easily download Eclipse for PHP on Windows, Linux and MAC, and the
 best part is that you can also easily find and add different plugins
 like SVN, JS, etc. Just check it out... ;-)

 Regards,
 Dusan

 On Mon, May 31, 2010 at 4:13 AM, Mark Kellyp...@wastedtimes.net  wrote:


 Hi.

 On Monday 31 May 2010 at 02:50 Ashley Sheridan wrote:


 Yeah, like I mentioned earlier, Dreamweaver is known for having issues
 with include files, can be slow when working on large projects with lots
 of files, and is only available for Mac and Windows, which limits it
 somewhat.


 Indeed. I can't stand the thing myself - I was just being polite :)

 I use netbeans on Linux and Windows, so its cross-platform nature is
 quite
 important to me. I also appreciate the Subversion integration, which is
 very
 nicely done.

 Tedd: I'm no expert, but I'll chime in if I have any answers for you.

 Cheers,

 Mark

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







 --

 Saludos / Best regards

 Mario Lacunza
 Email:: mlacu...@gmail.com
 Personal Website:: http://lacunza.biz/
 Hosting:: http://mlv-host.com/
 Google Talk: mlacunzav Skype: mlacunzav
 MSN: mlacun...@hotmail.com Y! messenger: mlacunzav


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



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



[PHP] NetBeans Question

2010-05-30 Thread tedd

Hi gang:

Do any of you use NetBeans for your IDE?

It looks like a great IDE, but I have some questions.

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] NetBeans Question

2010-05-30 Thread php

On 05/30/2010 05:57 PM, tedd wrote:

Hi gang:

Do any of you use NetBeans for your IDE?


Yes, i do. Since 2 Years (Netbeans 6.5 then), now with 6.8

I work very well with netbeans on Mac OS-X and Ubuntu, using SVN as 
version-backend, XDEBUG for debugging, Code-Coverage etc...



It looks like a great IDE, but I have some questions.



Tell me, maybe i can answer

Paul


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



Re: [PHP] NetBeans Question

2010-05-30 Thread Jason Pruim


On May 30, 2010, at 12:32 PM, php wrote:


On 05/30/2010 05:57 PM, tedd wrote:

Hi gang:

Do any of you use NetBeans for your IDE?


Yes, i do. Since 2 Years (Netbeans 6.5 then), now with 6.8

I work very well with netbeans on Mac OS-X and Ubuntu, using SVN as  
version-backend, XDEBUG for debugging, Code-Coverage etc...



It looks like a great IDE, but I have some questions.



Tell me, maybe i can answer



Hey tedd,

I actually just started using it a little bit ago as I wanted  
something more robust then just a text editor with some syntax  
highlighting :)


So feel free to ask away and I'll see what I can answer :)



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



Re: [PHP] NetBeans Question

2010-05-30 Thread Ashley Sheridan
On Sun, 2010-05-30 at 12:58 -0400, Jason Pruim wrote:

 On May 30, 2010, at 12:32 PM, php wrote:
 
  On 05/30/2010 05:57 PM, tedd wrote:
  Hi gang:
 
  Do any of you use NetBeans for your IDE?
 
  Yes, i do. Since 2 Years (Netbeans 6.5 then), now with 6.8
 
  I work very well with netbeans on Mac OS-X and Ubuntu, using SVN as  
  version-backend, XDEBUG for debugging, Code-Coverage etc...
 
  It looks like a great IDE, but I have some questions.
 
 
  Tell me, maybe i can answer
 
 
 Hey tedd,
 
 I actually just started using it a little bit ago as I wanted  
 something more robust then just a text editor with some syntax  
 highlighting :)
 
 So feel free to ask away and I'll see what I can answer :)
 
 
 


This thread has made me want to have a look at the IDE. Will the base
IDE package be enough, or is there something specific it needs for PHP
development, like a netbeans-php package? I'm using Linux (Fedora 11)
btw ;)

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




Re: [PHP] NetBeans Question

2010-05-30 Thread Ashley Sheridan
On Sun, 2010-05-30 at 13:48 -0400, Brandon Rampersad wrote:

 i use dreamweaver and it's better
 
 
 On Sun, May 30, 2010 at 1:01 PM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
 
 On Sun, 2010-05-30 at 12:58 -0400, Jason Pruim wrote:
 
  On May 30, 2010, at 12:32 PM, php wrote:
 
   On 05/30/2010 05:57 PM, tedd wrote:
   Hi gang:
  
   Do any of you use NetBeans for your IDE?
  
   Yes, i do. Since 2 Years (Netbeans 6.5 then), now with 6.8
  
   I work very well with netbeans on Mac OS-X and Ubuntu,
 using SVN as
   version-backend, XDEBUG for debugging, Code-Coverage
 etc...
  
   It looks like a great IDE, but I have some questions.
  
  
   Tell me, maybe i can answer
  
 
  Hey tedd,
 
  I actually just started using it a little bit ago as I
 wanted
  something more robust then just a text editor with some
 syntax
  highlighting :)
 
  So feel free to ask away and I'll see what I can answer :)
 
 
 
 
 
 
 
 This thread has made me want to have a look at the IDE. Will
 the base
 IDE package be enough, or is there something specific it needs
 for PHP
 development, like a netbeans-php package? I'm using Linux
 (Fedora 11)
 btw ;)
 
 
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 
 
 
 
 
 -- 
 A Brandon_R Production


I don't know about that. I prefer a standard text editor to Dreamweaver.
Dw is full of bloat, really screws up include files and isn't available
on Linux anyway. As an editor for people more visually orientated it's
not bad, but for someone coming from a programming background, it
hinders in many places.

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




Re: [PHP] NetBeans Question

2010-05-30 Thread tedd

At 6:01 PM +0100 5/30/10, Ashley Sheridan wrote:

This thread has made me want to have a look at the IDE. Will the base
IDE package be enough, or is there something specific it needs for PHP
development, like a netbeans-php package? I'm using Linux (Fedora 11)
btw ;)

Thanks,
Ash


Ash:

I'm really new at NetBeans and am having some minor questions I was 
keeping off-list -- however -- can go on list if there is interest.


As for specific needs that NetBeans requires being an IDE for php, 
they make a special one just for php, see here:


http://netbeans.org/downloads/index.html

Find the one that fits your needs, like the one that covers only php 
and download it -- that's what I did.


It's very easy to install and its learning curve is pretty easy. 
There are just some minor things that are not obvious, such as 
downloading a remote file to your local directory.


You see, I use two different computers and have two accesses to the 
same server. Occasionally, I may change a file remotely and my second 
computer needs to be updated. I know this could be solved via some 
version scheme, but I don't want to make a big production out of it 
-- all I need to do is download a remote file, but I didn't see an 
easy way to do that.


So, I searched for a couple of hours until I found someone said 
Simply, right-click on the file locally and choose 'download' and 
you'll overwrite the file -- that was simple enough. But I had to 
find out how to do it. These are the types of questions I have.


I wanted to ask my questions on the NetBeans forums, but I am having 
trouble logging in. They seem to have a problem with my given ID, 
password, and email address and I haven't the time to straighten it 
all out -- I just want answers -- so I turned to this list.


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] NetBeans Question

2010-05-30 Thread Mark Kelly
Hi Tedd.

On Sunday 30 May 2010 at 19:01 tedd wrote:
 I wanted to ask my questions on the NetBeans forums, but I am having
 trouble logging in. They seem to have a problem with my given ID,
 password, and email address and I haven't the time to straighten it
 all out -- I just want answers -- so I turned to this list.

Just in case you didn't spot it, there is a mailing list specifically for PHP 
development using netbeans that I have found very useful. You can sign up 
here:

http://netbeans.org/community/lists/top.html#technologies

Cheers,

Mark

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



Re: [PHP] NetBeans Question

2010-05-30 Thread Mark Kelly
Hi Brandon.

You sent your reply directly to me, instead of to the mailing list. 

Also I don't agree - netbeans is an excellent IDE and to call it a text editor 
is not doing it justice at all.

Cheers,

Mark

On Monday 31 May 2010 at 02:03 you wrote:

 Dreamweaver is better if you want a real IDE. If you want a regular text
 editor netbeans is the way to go.
 
 On Sun, May 30, 2010 at 8:15 PM, Mark Kelly p...@wastedtimes.net wrote:
  Hi Tedd.
 
  On Sunday 30 May 2010 at 19:01 tedd wrote:
   I wanted to ask my questions on the NetBeans forums, but I am having
   trouble logging in. They seem to have a problem with my given ID,
   password, and email address and I haven't the time to straighten it
   all out -- I just want answers -- so I turned to this list.
 
  Just in case you didn't spot it, there is a mailing list specifically for
  PHP
  development using netbeans that I have found very useful. You can sign up
  here:
 
  http://netbeans.org/community/lists/top.html#technologies
 
  Cheers,
 
  Mark
 
  --
  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] NetBeans Question

2010-05-30 Thread Ashley Sheridan
On Mon, 2010-05-31 at 02:46 +0100, Mark Kelly wrote:

 Hi Brandon.
 
 You sent your reply directly to me, instead of to the mailing list. 
 
 Also I don't agree - netbeans is an excellent IDE and to call it a text 
 editor 
 is not doing it justice at all.
 
 Cheers,
 
 Mark
 
 On Monday 31 May 2010 at 02:03 you wrote:
 
  Dreamweaver is better if you want a real IDE. If you want a regular text
  editor netbeans is the way to go.
  
  On Sun, May 30, 2010 at 8:15 PM, Mark Kelly p...@wastedtimes.net wrote:
   Hi Tedd.
  
   On Sunday 30 May 2010 at 19:01 tedd wrote:
I wanted to ask my questions on the NetBeans forums, but I am having
trouble logging in. They seem to have a problem with my given ID,
password, and email address and I haven't the time to straighten it
all out -- I just want answers -- so I turned to this list.
  
   Just in case you didn't spot it, there is a mailing list specifically for
   PHP
   development using netbeans that I have found very useful. You can sign up
   here:
  
   http://netbeans.org/community/lists/top.html#technologies
  
   Cheers,
  
   Mark
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 


Yeah, like I mentioned earlier, Dreamweaver is known for having issues
with include files, can be slow when working on large projects with lots
of files, and is only available for Mac and Windows, which limits it
somewhat.

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




Re: [PHP] NetBeans Question

2010-05-30 Thread Mark Kelly
Hi.

On Monday 31 May 2010 at 02:50 Ashley Sheridan wrote:
 Yeah, like I mentioned earlier, Dreamweaver is known for having issues
 with include files, can be slow when working on large projects with lots
 of files, and is only available for Mac and Windows, which limits it
 somewhat.

Indeed. I can't stand the thing myself - I was just being polite :)

I use netbeans on Linux and Windows, so its cross-platform nature is quite 
important to me. I also appreciate the Subversion integration, which is very 
nicely done.

Tedd: I'm no expert, but I'll chime in if I have any answers for you.

Cheers,

Mark

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



Re: [PHP] Content question

2010-05-20 Thread tedd

At 1:07 PM -0400 5/19/10, Ernie Kemp wrote:

This is not a direct PHP question but I will be using PHP in the website.

After a website has been created there will a need to changes say a 
product or service page over time.

The client asking how he will be able to make changes to these pages.
Yes, I'm a newbie at this and the only way I can think of is to edit 
the page in say a HTML editor.


Please comment how you might do it another way.

Thanks very much,
/Ernie


Hire one of us to do it. That's what many of us do for a living.

Cheers,

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

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



[PHP] Content question

2010-05-19 Thread Ernie Kemp
 

This is not a direct PHP question but I will be using PHP in the website.

 

After a website has been created there will a need to changes say a product
or service page over time.

The client asking how he will be able to make changes to these pages.

Yes, I'm a newbie at this and the only way I can think of is to edit the
page in say a HTML editor.

 

Please comment how you might do it another way.

 

Thanks very much,

/Ernie

 

 

 

 

 



Re: [PHP] Content question

2010-05-19 Thread Ashley Sheridan
On Wed, 2010-05-19 at 13:07 -0400, Ernie Kemp wrote:

 
 
 This is not a direct PHP question but I will be using PHP in the
 website.
 
  
 
 After a website has been created there will a need to changes say a
 product or service page over time.
 
 The client asking how he will be able to make changes to these pages.
 
 Yes, I’m a newbie at this and the only way I can think of is to edit
 the page in say a HTML editor.
 
  
 
 Please comment how you might do it another way.
 
  
 
 Thanks very much,
 
 /Ernie
 
  
 
  
 
  
 
  
 
  
 
 

You need some sort of content management system (CMS) for it. For
something as simple as this it's not too difficult to build a basic app
yourself, or you could use a pre-built system such as WordPress, Drupal,
Joomla or PHPNuke.

If you've already got the site built as a series of HTML pages, it might
be worth converting those into .php files and then taking out all the
common elements and put them into include files. That way, if you need
to update the navigation bar, for example, you just need to edit the
navbar include file once.

I tend to store all the individual content for pages inside a database
and then pull it out as I need it. This makes it easy to add in features
such as a site search. I use the CKEditor rich text Javascript component
to allow the user to format their content (I often limit the options
available to them so they don't break stuff!) and give them basic
options such as adding content and updating content like that.

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




[PHP] Parse question

2010-05-13 Thread Ron Piggott

If $message_body contains:

$message_body=You are subscribed using u...@domain. To update;

How do I capture just the e-mail address?

Ron



Re: [PHP] Parse question

2010-05-13 Thread Cemal Eker
Check this out.  http://www.regular-expressions.info/email.html
---
“Talk is cheap. Show me the code” - Linus Torvalds


On Thu, May 13, 2010 at 7:34 AM, Ron Piggott ron.pigg...@actsministries.org
 wrote:


 If $message_body contains:

 $message_body=You are subscribed using u...@domain. To update;

 How do I capture just the e-mail address?

 Ron




RE: [PHP] Parse question

2010-05-13 Thread Lawrance Shepstone
-Original Message-
From: Ron Piggott [mailto:ron.pigg...@actsministries.org] 
Sent: 13 May 2010 06:34 AM
To: PHP General
Subject: [PHP] Parse question


If $message_body contains:

$message_body=You are subscribed using u...@domain. To update;

How do I capture just the e-mail address?

Ron

__

Regular Expressions ... They're great at this sort of thing!

I'd suggest starting here:

http://www.regular-expressions.info/email.html

Then take a look at the PHP regular expression manual:

http://www.php.net/manual/en/book.pcre.php

Have fun!
Lawrance


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



[PHP] Malware Question

2010-04-28 Thread Ashley Sheridan
Hi all,

This isn't exactly a PHP question, but I don't know anyone else with the
collected smarts of this list. Basically, a site I built and am managing
has been identified by Google as a source of malware. Now, I've been
over the source code with a fine-toothed comb and found nothing, I've
gone over the HTML output for anything suspicious, checked ever single
Javascript file out, looked to see the server headers are correct and
aren't malformed, checked the .htaccess is as expected and have run the
site against the unmask parasites website which found no problems except
the 'suspicious' listing which Google has given it.

The Google webmaster tools tell me nothing more than 'Of the 2 pages we
tested on the site over the past 90 days, 2 page(s) resulted in
malicious software being downloaded and installed without user consent.'
It won't tell me what pages, although it tells me that the malicious
software is hosted on one domain and tells me what it is. Needless to
say I can't find that domain string anywhere in the code. I can't find
any hidden iframe tags or hidden Javascript eval() statements.

Basically now, although this is totally beyond my control, the owner of
the site is expecting me to get this sorted asap. I want to, and have
spent the entire day today looking at it, but have really come to the
point where I'm coming unstuck. I can find nothing wrong with the site
at all.

Does anyone have any helpful advice for this sort of thing? Tools that I
can use to check out the site with, or any bit of information that I can
use to fix this? I can give the URL of the site to anyone off-list if
they wish to check it out.

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




Re: [PHP] Malware Question

2010-04-28 Thread Daniel Brown
On Wed, Apr 28, 2010 at 19:50, Ashley Sheridan a...@ashleysheridan.co.uk 
wrote:

 The Google webmaster tools tell me nothing more than 'Of the 2 pages we
 tested on the site over the past 90 days, 2 page(s) resulted in
 malicious software being downloaded and installed without user consent.'
 It won't tell me what pages, although it tells me that the malicious
 software is hosted on one domain and tells me what it is. Needless to
 say I can't find that domain string anywhere in the code. I can't find
 any hidden iframe tags or hidden Javascript eval() statements.

Ash, let me know off-list what the domain is and I'll try to do a
scan on it from here this evening.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

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



Re: [PHP] Math Question....

2010-04-23 Thread Richard Quadling
On 22 April 2010 17:47, Developer Team d...@thebat.net wrote:
 Awesome source.
 Thanks

 On 4/22/10, Richard Quadling rquadl...@googlemail.com wrote:
 On 22 April 2010 14:48, Dan Joseph dmjos...@gmail.com wrote:
 On Thu, Apr 22, 2010 at 10:29 AM, Richard Quadling
 rquadl...@googlemail.com
 wrote:

  
  It sounds like you are looking for factors.
 
 
 http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver
 
  Solution by Find factors of any number
 
  1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
  Work Shown
 
  1252398 is divisible by 2: 1252398 = 626199 * 2.
  626199 is divisible by 3: 626199 = 208733 * 3.
  208733 is divisible by 7: 208733 = 29819 * 7.
  29819 is not divisible by anything.
 
  So 29819 by 42 (7*3*2)
 
  would be a route.

 Aha. Missed the 30 bit.

 So, having found the factors, you would need to process them to find
 the largest combination under 30.

 2*3
 2*3*7
 2*7
 3*7

 are the possibilities (ignoring any number over 30).

 Of which 3*7 is the largest.

 So, 1,252,398 divided by 21 = 59,638


 Is that the sort of thing you are looking for?



 Yes, that looks exactly what like what I'm looking for.  I'm going to try
 and wake up the algebra side of my brain that hasn't been used in years
 and
 see if I can digest all this.

 For the 2, 3, and 7, that is based solely on the last number being
 divisible
 by a prime number?

 Joao, Jason, thanks for the code.

 --
 -Dan Joseph

 www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
 Code NEWTHINGS for 10% off initial order

 http://www.facebook.com/canishosting
 http://www.facebook.com/originalpoetry


 This seems to be working ...

 ?php
 function findBestFactors($Value, $GroupSize, array $Factors = null)
       {
       $Factors = array();
       foreach(range(1, ceil(sqrt($Value))) as $Factor)
               {
               if (0 == ($Value % $Factor))
                       {
                       if ($Factor = $GroupSize)
                               {
                               $Factors[] = $Factor;
                               }
                       if ($Factor != ($OtherFactor = ($Value / $Factor))  
 $OtherFactor
 = $GroupSize)
                               {
                               $Factors[] = $OtherFactor;
                               }
                       }

               if ($Factor = $GroupSize)
                       {
                       break;
                       }
               }

       rsort($Factors);

       return reset($Factors);
       }

 echo findBestFactors($argv[1], $argv[2], $Factors), PHP_EOL;
 ?


 factors 1252398988 5000

 outputs  ...

 4882

 and 21 for your value 1252398

 --
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling

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




Thank you. It was a quick knock up, so could probably be optimized a
little more.

It will also not work beyond PHP_MAX_INT, unless the code is converted
to use the BCMath or GMP extension.

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Math Question....

2010-04-23 Thread Dotan Cohen
On 22 April 2010 17:07, Dan Joseph dmjos...@gmail.com wrote:
 Howdy,

 This is a math question, but I'm doing the code in PHP, and have expunged
 all resources... hoping someone can guide me here.  For some reason, I can't
 figure this out.

 I want to take a group of items, and divide them into equal groups based on
 a max per group.  Example.

 1,252,398 -- divide into equal groups with only 30 items per group max.

 Can anyone guide me towards an algorithm or formula name to solve this?  PHP
 code or Math stuff is fine.  Either way...

 Thanks...


What is wrong with 626,299 groups of 2 items each (done in my head, so
I might be off a little)?

-- 
Dotan Cohen

http://bido.com
http://what-is-what.com

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



Re: [PHP] Math Question....

2010-04-23 Thread Richard Quadling
On 23 April 2010 13:33, Dotan Cohen dotanco...@gmail.com wrote:
 What is wrong with 626,299 groups of 2 items each (done in my head, so
 I might be off a little)?

2, 3, 6, 7, 14 and 21 are all valid.


-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Math Question....

2010-04-23 Thread tedd

At 10:17 AM -0400 4/22/10, Dan Joseph wrote:

On Thu, Apr 22, 2010 at 10:12 AM, Stephen stephe...@rogers.com wrote:


 1,252,398 DIV 30 = 41,746 groups of 30.

 1,252,398 MOD 30 = 18 items in last group


Well, the only problem with going that route, is the one group is not
equally sized to the others.  18 is ok for a group in this instance, but if
it was a remainder of only 1 or 2, there would be an issue.  Which is where
I come to looking for a the right method to break it equally.

--
-Dan Joseph



_Dan:

As I see it -- you are asking is What would be the 'optimum' group 
size for 1,252,398?


Optimum here meaning:

1. A group size of 30 or under;
2. All groups being of equal size.

Is that correct?

There may not be an exact solution, but a first order attempt would 
be to divide the total number by 30 and check the remainder (i.e., 
MOD), the do the same for 29, 28, 27... and so on.


The group size solution would be a number with a zero remainder OR 
with a remainder closest to your group size.


That would be my first blush solution.

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] Math Question....

2010-04-23 Thread Richard Quadling
?php
function findBestFactors($Value, $GroupSize = INF)
{
foreach(range(min($GroupSize, ceil(sqrt($Value))), 1) as $Factor)
{
if (0 == ($Value % $Factor))
{
return array($Factor, $Value / $Factor);
}
}
}

list($Groups, $Size) = findBestFactors($argv[1], isset($argv[2]) ?
$argv[2] : INF);
echo $Groups groups of $Size;
?

Supply a value and an optional maximum group size.

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



[PHP] Math Question....

2010-04-22 Thread Dan Joseph
Howdy,

This is a math question, but I'm doing the code in PHP, and have expunged
all resources... hoping someone can guide me here.  For some reason, I can't
figure this out.

I want to take a group of items, and divide them into equal groups based on
a max per group.  Example.

1,252,398 -- divide into equal groups with only 30 items per group max.

Can anyone guide me towards an algorithm or formula name to solve this?  PHP
code or Math stuff is fine.  Either way...

Thanks...

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Math Question....

2010-04-22 Thread Stephen

Dan Joseph wrote:

I want to take a group of items, and divide them into equal groups based on
a max per group.  Example.

1,252,398 -- divide into equal groups with only 30 items per group max.


  

1,252,398 DIV 30 = 41,746 groups of 30.

1,252,398 MOD 30 = 18 items in last group

Stephen


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



Re: [PHP] Math Question....

2010-04-22 Thread Dan Joseph
On Thu, Apr 22, 2010 at 10:12 AM, Stephen stephe...@rogers.com wrote:

 1,252,398 DIV 30 = 41,746 groups of 30.

 1,252,398 MOD 30 = 18 items in last group

Well, the only problem with going that route, is the one group is not
equally sized to the others.  18 is ok for a group in this instance, but if
it was a remainder of only 1 or 2, there would be an issue.  Which is where
I come to looking for a the right method to break it equally.

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Math Question....

2010-04-22 Thread Ashley Sheridan
On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:

 On Thu, Apr 22, 2010 at 10:12 AM, Stephen stephe...@rogers.com wrote:
 
  1,252,398 DIV 30 = 41,746 groups of 30.
 
  1,252,398 MOD 30 = 18 items in last group
 
 Well, the only problem with going that route, is the one group is not
 equally sized to the others.  18 is ok for a group in this instance, but if
 it was a remainder of only 1 or 2, there would be an issue.  Which is where
 I come to looking for a the right method to break it equally.
 


How do you mean break it equally? If the number doesn't fit, then you've
got a remainder, and no math is going to change that. How do you want
that remainder distributed?

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




Re: [PHP] Math Question....

2010-04-22 Thread Richard Quadling
On 22 April 2010 15:13, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:

 On Thu, Apr 22, 2010 at 10:12 AM, Stephen stephe...@rogers.com wrote:

  1,252,398 DIV 30 = 41,746 groups of 30.
 
  1,252,398 MOD 30 = 18 items in last group
 
 Well, the only problem with going that route, is the one group is not
 equally sized to the others.  18 is ok for a group in this instance, but if
 it was a remainder of only 1 or 2, there would be an issue.  Which is where
 I come to looking for a the right method to break it equally.



 How do you mean break it equally? If the number doesn't fit, then you've
 got a remainder, and no math is going to change that. How do you want
 that remainder distributed?

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




It sounds like you are looking for factors.

http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver

Solution by Find factors of any number

1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
Work Shown

1252398 is divisible by 2: 1252398 = 626199 * 2.
626199 is divisible by 3: 626199 = 208733 * 3.
208733 is divisible by 7: 208733 = 29819 * 7.
29819 is not divisible by anything.

So 29819 by 42 (7*3*2)

would be a route.


Take note of 
http://www.algebra.com/algebra/homework/divisibility/Prime_factorization_algorithm.wikipedia,
which has the comment ...

Many cryptographic protocols are based on the difficultly of
factoring large composite integers or a related problem, the RSA
problem. An algorithm which efficiently factors an arbitrary integer
would render RSA-based public-key cryptography insecure..




-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Math Question....

2010-04-22 Thread Richard Quadling
On 22 April 2010 15:26, Richard Quadling rquadl...@googlemail.com wrote:
 On 22 April 2010 15:13, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:

 On Thu, Apr 22, 2010 at 10:12 AM, Stephen stephe...@rogers.com wrote:

  1,252,398 DIV 30 = 41,746 groups of 30.
 
  1,252,398 MOD 30 = 18 items in last group
 
 Well, the only problem with going that route, is the one group is not
 equally sized to the others.  18 is ok for a group in this instance, but if
 it was a remainder of only 1 or 2, there would be an issue.  Which is where
 I come to looking for a the right method to break it equally.



 How do you mean break it equally? If the number doesn't fit, then you've
 got a remainder, and no math is going to change that. How do you want
 that remainder distributed?

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




 It sounds like you are looking for factors.

 http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver

 Solution by Find factors of any number

 1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
 Work Shown

 1252398 is divisible by 2: 1252398 = 626199 * 2.
 626199 is divisible by 3: 626199 = 208733 * 3.
 208733 is divisible by 7: 208733 = 29819 * 7.
 29819 is not divisible by anything.

 So 29819 by 42 (7*3*2)

 would be a route.


 Take note of 
 http://www.algebra.com/algebra/homework/divisibility/Prime_factorization_algorithm.wikipedia,
 which has the comment ...

 Many cryptographic protocols are based on the difficultly of
 factoring large composite integers or a related problem, the RSA
 problem. An algorithm which efficiently factors an arbitrary integer
 would render RSA-based public-key cryptography insecure..




 --
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling


Aha. Missed the 30 bit.

So, having found the factors, you would need to process them to find
the largest combination under 30.

2*3
2*3*7
2*7
3*7

are the possibilities (ignoring any number over 30).

Of which 3*7 is the largest.

So, 1,252,398 divided by 21 = 59,638


Is that the sort of thing you are looking for?

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



RE: [PHP] Math Question....

2010-04-22 Thread Jason
-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 22 April 2010 15:13
To: Dan Joseph
Cc: PHP eMail List
Subject: Re: [PHP] Math Question

On Thu, 2010-04-22 at 10:17 -0400, Dan Joseph wrote:

 On Thu, Apr 22, 2010 at 10:12 AM, Stephen stephe...@rogers.com wrote:
 
  1,252,398 DIV 30 = 41,746 groups of 30.
 
  1,252,398 MOD 30 = 18 items in last group
 
 Well, the only problem with going that route, is the one group is not
 equally sized to the others.  18 is ok for a group in this instance, but
if
 it was a remainder of only 1 or 2, there would be an issue.  Which is
where
 I come to looking for a the right method to break it equally.
 


How do you mean break it equally? If the number doesn't fit, then you've
got a remainder, and no math is going to change that. How do you want
that remainder distributed?

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




Perhaps a round-robin approach is called for?

?
$items=1252398;
$groupsize=30;

for ($i=0;$i$items;$i++)
$grouparray[$i % $groupsize][]=$i;


print_r($grouparray);
?

HTH
J


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



Re: [PHP] Math Question....

2010-04-22 Thread Dan Joseph
On Thu, Apr 22, 2010 at 10:29 AM, Richard Quadling rquadl...@googlemail.com
 wrote:

  
  It sounds like you are looking for factors.
 
 
 http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver
 
  Solution by Find factors of any number
 
  1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
  Work Shown
 
  1252398 is divisible by 2: 1252398 = 626199 * 2.
  626199 is divisible by 3: 626199 = 208733 * 3.
  208733 is divisible by 7: 208733 = 29819 * 7.
  29819 is not divisible by anything.
 
  So 29819 by 42 (7*3*2)
 
  would be a route.

 Aha. Missed the 30 bit.

 So, having found the factors, you would need to process them to find
 the largest combination under 30.

 2*3
 2*3*7
 2*7
 3*7

 are the possibilities (ignoring any number over 30).

 Of which 3*7 is the largest.

 So, 1,252,398 divided by 21 = 59,638


 Is that the sort of thing you are looking for?



Yes, that looks exactly what like what I'm looking for.  I'm going to try
and wake up the algebra side of my brain that hasn't been used in years and
see if I can digest all this.

For the 2, 3, and 7, that is based solely on the last number being divisible
by a prime number?

Joao, Jason, thanks for the code.

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Math Question....

2010-04-22 Thread Peter van der Does
On Thu, 22 Apr 2010 10:17:10 -0400
Dan Joseph dmjos...@gmail.com wrote:

 On Thu, Apr 22, 2010 at 10:12 AM, Stephen stephe...@rogers.com
 wrote:
 
  1,252,398 DIV 30 = 41,746 groups of 30.
 
  1,252,398 MOD 30 = 18 items in last group
 
 Well, the only problem with going that route, is the one group is not
 equally sized to the others.  18 is ok for a group in this instance,
 but if it was a remainder of only 1 or 2, there would be an issue.
 Which is where I come to looking for a the right method to break it
 equally.
 

My take on it:

$Items=1252398;
$MaxInGroup=30;
for ($x=$MaxInGroup; $x1;$x--) {
$remainder=$Items % $x;
// Change 17 to the max amount allowed in the last group
if ($remainder == 0 || $remainder = 17) { // 
$groups = (int) ($Items /$x)+1;
echo $groups.\n;
echo $remainder;
break;
}
}

-- 
Peter van der Does

GPG key: E77E8E98

IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes

WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware

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



Re: [PHP] Math Question....

2010-04-22 Thread Peter van der Does
On Thu, 22 Apr 2010 10:49:11 -0400
Peter van der Does pvanderd...@gmail.com wrote:


 
 My take on it:
 
 $Items=1252398;
 $MaxInGroup=30;
 for ($x=$MaxInGroup; $x1;$x--) {
   $remainder=$Items % $x;
   // Change 17 to the max amount allowed in the last group
   if ($remainder == 0 || $remainder = 17) { // 
   $groups = (int) ($Items /$x)+1;
   echo $groups.\n;
   echo $remainder;
   break;
   }
 }
 
Bugfixed LOL:
$Items=1252398;
$MaxInGroup=30;
for ($x=$MaxInGroup; $x1;$x--) {
$remainder=$Items % $x;
// Change 17 to the max amount allowed in a group
if ($remainder == 0 || $remainder = 17) {
$groups = (int) ($Items /$x);
if ($remainder  0 ) {
$groups++;
}
echo $groups.\n;
echo $remainder;
break;
}
}

-- 
Peter van der Does

GPG key: E77E8E98

IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes

WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware

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



Re: [PHP] Math Question....

2010-04-22 Thread Richard Quadling
On 22 April 2010 14:48, Dan Joseph dmjos...@gmail.com wrote:
 On Thu, Apr 22, 2010 at 10:29 AM, Richard Quadling rquadl...@googlemail.com
 wrote:

  
  It sounds like you are looking for factors.
 
 
 http://www.algebra.com/algebra/homework/divisibility/factor-any-number-1.solver
 
  Solution by Find factors of any number
 
  1252398 is NOT a prime number: 1252398 = 2 * 3 * 7 * 29819
  Work Shown
 
  1252398 is divisible by 2: 1252398 = 626199 * 2.
  626199 is divisible by 3: 626199 = 208733 * 3.
  208733 is divisible by 7: 208733 = 29819 * 7.
  29819 is not divisible by anything.
 
  So 29819 by 42 (7*3*2)
 
  would be a route.

 Aha. Missed the 30 bit.

 So, having found the factors, you would need to process them to find
 the largest combination under 30.

 2*3
 2*3*7
 2*7
 3*7

 are the possibilities (ignoring any number over 30).

 Of which 3*7 is the largest.

 So, 1,252,398 divided by 21 = 59,638


 Is that the sort of thing you are looking for?



 Yes, that looks exactly what like what I'm looking for.  I'm going to try
 and wake up the algebra side of my brain that hasn't been used in years and
 see if I can digest all this.

 For the 2, 3, and 7, that is based solely on the last number being divisible
 by a prime number?

 Joao, Jason, thanks for the code.

 --
 -Dan Joseph

 www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
 Code NEWTHINGS for 10% off initial order

 http://www.facebook.com/canishosting
 http://www.facebook.com/originalpoetry


This seems to be working ...

?php
function findBestFactors($Value, $GroupSize, array $Factors = null)
{
$Factors = array();
foreach(range(1, ceil(sqrt($Value))) as $Factor)
{
if (0 == ($Value % $Factor))
{
if ($Factor = $GroupSize)
{
$Factors[] = $Factor;
}
if ($Factor != ($OtherFactor = ($Value / $Factor))  
$OtherFactor
= $GroupSize)
{
$Factors[] = $OtherFactor;
}
}

if ($Factor = $GroupSize)
{
break;
}
}

rsort($Factors);

return reset($Factors);
}

echo findBestFactors($argv[1], $argv[2], $Factors), PHP_EOL;
?


factors 1252398988 5000

outputs  ...

4882

and 21 for your value 1252398

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Math Question....

2010-04-22 Thread Dan Joseph
On Thu, Apr 22, 2010 at 12:16 PM, Richard Quadling rquadl...@googlemail.com
 wrote:

  On 22 April 2010 14:48, Dan Joseph dmjos...@gmail.com wrote:
 This seems to be working ...

 ?php
 function findBestFactors($Value, $GroupSize, array $Factors = null)
{
$Factors = array();
foreach(range(1, ceil(sqrt($Value))) as $Factor)
{
if (0 == ($Value % $Factor))
{
if ($Factor = $GroupSize)
{
$Factors[] = $Factor;
}
if ($Factor != ($OtherFactor = ($Value / $Factor))
  $OtherFactor
 = $GroupSize)
{
$Factors[] = $OtherFactor;
}
}

if ($Factor = $GroupSize)
{
break;
}
}

rsort($Factors);

return reset($Factors);
}

 echo findBestFactors($argv[1], $argv[2], $Factors), PHP_EOL;
 ?


 factors 1252398988 5000

 outputs  ...

 4882

 and 21 for your value 1252398



Wow!  thanks...  I just plopped it into phped and fired off some tests, and
I agree, seems to work fine.  I appreciate your help today.  I am still
looking over the algebra stuff, and am now comparing it to your code.  This
will get me moving forward better in my project.  Thank you!

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-09 Thread Rene Veerman
cmon, just search for ubuntu install lamp via google..

or google for download ubuntu, select the stable branch (karmic),
install it, and then type this into a terminal window:

sudo apt-get install apache2 mysql5 php5

from there, running LAMP development on linux should be a breeze for you.


On Thu, Apr 8, 2010 at 1:42 PM, Bastien Helders eldroskan...@gmail.com wrote:
 Hi List,

 The other day, I read an article that mentioned about a tool that would
 permit to simulate a web environment for PHP, so that testing could be made
 before uploading the page on the server. Unfortunately, I don't seem to find
 the article again.

 So here am I with this question: What should I need to set my test
 environment? I'm working on Windows, but I'm all ears for solution on Linux
 systems.

 Best Regards,
 Bastien


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



[PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Bastien Helders
Hi List,

The other day, I read an article that mentioned about a tool that would
permit to simulate a web environment for PHP, so that testing could be made
before uploading the page on the server. Unfortunately, I don't seem to find
the article again.

So here am I with this question: What should I need to set my test
environment? I'm working on Windows, but I'm all ears for solution on Linux
systems.

Best Regards,
Bastien


Re: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 13:42 +0200, Bastien Helders wrote:

 Hi List,
 
 The other day, I read an article that mentioned about a tool that would
 permit to simulate a web environment for PHP, so that testing could be made
 before uploading the page on the server. Unfortunately, I don't seem to find
 the article again.
 
 So here am I with this question: What should I need to set my test
 environment? I'm working on Windows, but I'm all ears for solution on Linux
 systems.
 
 Best Regards,
 Bastien


The easiest thing is to set up a local web server on your machine to
test with. This isn't as daunting as it sounds, as there are a lot of
ways you can get this set up with a minimum of fuss. The easiest to use
software I've used for Windows was EasyPHP, which is basically a WAMP
stack that is GUI all the way, allows easy add/drop of extra modules,
and now ever comes with an English installer (it used to be all in
French which made it a little tricky to understand!)

Otherwise, if you want to try the Linux route you can set this up on a
second machine, dual-boot with Windows or run inside a virtual machine
(Virtual Machine OSE is open source and free to use). I've not seen a
Linux distribution yet that didn't offer Apache and PHP. Generally a web
server will run something like Fedora, RedHat or CentOS, so using one of
those will get you a very similar set-up.

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




Re: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Midhun Girish
The best option in windows would be xampp or wamp same goes true
with linux.


Midhun Girish



On Thu, Apr 8, 2010 at 5:12 PM, Bastien Helders eldroskan...@gmail.com wrote:
 Hi List,

 The other day, I read an article that mentioned about a tool that would
 permit to simulate a web environment for PHP, so that testing could be made
 before uploading the page on the server. Unfortunately, I don't seem to find
 the article again.

 So here am I with this question: What should I need to set my test
 environment? I'm working on Windows, but I'm all ears for solution on Linux
 systems.

 Best Regards,
 Bastien


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



Re: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 17:24 +0530, Midhun Girish wrote:

 The best option in windows would be xampp or wamp same goes true
 with linux.
 
 
 Midhun Girish
 
 
 
 On Thu, Apr 8, 2010 at 5:12 PM, Bastien Helders eldroskan...@gmail.com 
 wrote:
  Hi List,
 
  The other day, I read an article that mentioned about a tool that would
  permit to simulate a web environment for PHP, so that testing could be made
  before uploading the page on the server. Unfortunately, I don't seem to find
  the article again.
 
  So here am I with this question: What should I need to set my test
  environment? I'm working on Windows, but I'm all ears for solution on Linux
  systems.
 
  Best Regards,
  Bastien
 
 


I'm not too sure that WAMP would be the best option for Linux :p

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




RE: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Tom Calpin
 Hi List,

 

 The other day, I read an article that mentioned about a tool that would

 permit to simulate a web environment for PHP, so that testing could be
made

 before uploading the page on the server. Unfortunately, I don't seem to
find

 the article again.

 

 So here am I with this question: What should I need to set my test

 environment? I'm working on Windows, but I'm all ears for solution on
Linux

 systems.

 

 Best Regards,

 Bastien

 

 

A couple of IDEs have web servers built in (NuSphere PhpED is the only one I
can remember at the moment) which can generally be used to preview your
applications offline, although you might struggle to get it running if it
requires a database connection, depending on your hosting config (my hosting
will only allow local connections to the DB). 

 

Alternatively, something like EasyPHP http://www.easyphp.org/ makes it very
easy to get a LAMP server set-up going on your machine, so you could drop
your app into the www folder and navigate to localhost on your web browser
to view it. Stick some dummy data in the db and you have a fully functional
version of your app running on your machine.



Re: [PHP] image question again

2010-04-07 Thread Ashley Sheridan
On Tue, 2010-04-06 at 21:44 -0500, Karl DeSaulniers wrote:

 When I have an imagecreatetruecolor and I create another one and use  
 imagecopymerge, how do I keep the backgrounds transparent even if say  
 the width of the top image is smaller than the back image?
 I keep getting a black background where the top image does not cover  
 the back. It sets the transparency to the rest of the top image as  
 long as it is covering the bottom one. I think it has to do with the  
 imagealphablending.
 Any ideas?
 TIA
 
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com
 


If it's just that the images are different sizes, then imagecopyresample
might be the better option.

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




[PHP] image question again

2010-04-06 Thread Karl DeSaulniers
When I have an imagecreatetruecolor and I create another one and use  
imagecopymerge, how do I keep the backgrounds transparent even if say  
the width of the top image is smaller than the back image?
I keep getting a black background where the top image does not cover  
the back. It sets the transparency to the rest of the top image as  
long as it is covering the bottom one. I think it has to do with the  
imagealphablending.

Any ideas?
TIA

Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP] Newbie Question about Conditionals

2010-03-31 Thread Richard Quadling
On 31 March 2010 05:45, Matty Sarro msa...@gmail.com wrote:
 That explains it perfectly, thanks you!

 On Wed, Mar 31, 2010 at 12:40 AM, Tommy Pham tommy...@gmail.com wrote:

 On Tue, Mar 30, 2010 at 9:22 PM, Matty Sarro msa...@gmail.com wrote:
  Hey all!
  This is probably my second post on the list, so please be gentle. Right
 now
  I am running through the Heads First PHP and MySQL book from O'Reilly.
  It's been quite enjoyable so far, but I have some questions about some of
  the code they're using in one of the chapters.
 
  Basically the code is retreiving rows from a DB, and I'm just not getting
  the explanation of how it works.
 
  Here's the code:
 
  $result=mysqli_query($dbc,$query)
 
  while($row=mysqli_fetch_array($result)){
  echo $row['first_name'].' '.$row['last_name'].' : '. $row['email'] . 'br
  /';
  }
 
  Now, I know what it does, but I don't understand how the conditional
  statement in the while loop works. Isn't an assignment operation always
  going to result in a true condition? Even if
 mysqli_fetch_array($result)
  returned empty values (or null) wouldn't the actual assignment to $row
 still
  be considered a true statement? I would have sworn that assignment
  operations ALWAYS equated to true if used in conditional operations.
  Please help explain! :)
 
  Thanks so much!
  -Matty
 

 http://www.php.net/manual/en/function.mysql-fetch-array.php

 Returns an array of strings that corresponds to the fetched row, or
 FALSE  if there are no more rows.

 while($row=mysqli_fetch_array($result)) is equivalent to this:

 $row=mysqli_fetch_array($result);
 while ($row){

 // do something

 $row=mysqli_fetch_array($result);
 }

 So, if $row is not equal to FALSE, the loop will happens.



Another part to the answer is the value of the assignment. From the
documentation (http://docs.php.net/manual/en/language.operators.assignment.php),
...

The value of an assignment expression is the value assigned.

while($row = mysqli_fetch_array($result))


But there is a significant issue here. Whilst not attributable to the
mysqli_fetch_array() function, it is certainly possible to give
yourself a significant WTF moment with it.


May be will be easier to see the problem when the code is written as ...

while(False === ($row = mysqli_fetch_array($result)))

No?


If I say ...

0 == False

does that help?



Without running the 2 stupid scripts  below, what output should you get?

?php while($pos = strpos('abc', 'a')) { echo 'a';} ?

and

?php while($pos = strpos('abc', 'z')) { echo 'z';} ?

Clearly, they should be different, yes?

Unfortunately, they won't be.

The first call returns 0 and the second returns False.

And as 0 == False, the while() does not loop.

But ...

?php while(False !== ($pos = strpos('abc', 'a'))) { echo 'a';} ?

and

?php while(False !== ($pos = strpos('abc', 'z'))) { echo 'z';} ?

now operate correctly. The first one runs forever, printing a's and
the second one quits straight away.

By always using ...

while(False !== ($var = function($param)))

you can clearly differentiate between functions that return false to
indicate failure and 0 to indicate a position or actual value.

Regards,

Richard.





-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Newbie Question about Conditionals

2010-03-31 Thread Matty Sarro
After looking up the === operator, I see exactly what you mean. Thanks for
your help everyone. I think the confusion was that I was always under the
impression that assignment is either true or false; I would never have
guessed it was equal to the value assigned. Your examples really helped to
solidify the concept though!

PS: I have to say that PHP has the *best* documentation I've ever seen
beside Java.

Thanks again!

On Wed, Mar 31, 2010 at 4:43 AM, Richard Quadling
rquadl...@googlemail.comwrote:

 On 31 March 2010 05:45, Matty Sarro msa...@gmail.com wrote:
  That explains it perfectly, thanks you!
 
  On Wed, Mar 31, 2010 at 12:40 AM, Tommy Pham tommy...@gmail.com wrote:
 
  On Tue, Mar 30, 2010 at 9:22 PM, Matty Sarro msa...@gmail.com wrote:
   Hey all!
   This is probably my second post on the list, so please be gentle.
 Right
  now
   I am running through the Heads First PHP and MySQL book from
 O'Reilly.
   It's been quite enjoyable so far, but I have some questions about some
 of
   the code they're using in one of the chapters.
  
   Basically the code is retreiving rows from a DB, and I'm just not
 getting
   the explanation of how it works.
  
   Here's the code:
  
   $result=mysqli_query($dbc,$query)
  
   while($row=mysqli_fetch_array($result)){
   echo $row['first_name'].' '.$row['last_name'].' : '. $row['email'] .
 'br
   /';
   }
  
   Now, I know what it does, but I don't understand how the conditional
   statement in the while loop works. Isn't an assignment operation
 always
   going to result in a true condition? Even if
  mysqli_fetch_array($result)
   returned empty values (or null) wouldn't the actual assignment to $row
  still
   be considered a true statement? I would have sworn that assignment
   operations ALWAYS equated to true if used in conditional operations.
   Please help explain! :)
  
   Thanks so much!
   -Matty
  
 
  http://www.php.net/manual/en/function.mysql-fetch-array.php
 
  Returns an array of strings that corresponds to the fetched row, or
  FALSE  if there are no more rows.
 
  while($row=mysqli_fetch_array($result)) is equivalent to this:
 
  $row=mysqli_fetch_array($result);
  while ($row){
 
  // do something
 
  $row=mysqli_fetch_array($result);
  }
 
  So, if $row is not equal to FALSE, the loop will happens.
 
 

 Another part to the answer is the value of the assignment. From the
 documentation (
 http://docs.php.net/manual/en/language.operators.assignment.php),
 ...

 The value of an assignment expression is the value assigned.

 while($row = mysqli_fetch_array($result))


 But there is a significant issue here. Whilst not attributable to the
 mysqli_fetch_array() function, it is certainly possible to give
 yourself a significant WTF moment with it.


 May be will be easier to see the problem when the code is written as ...

 while(False === ($row = mysqli_fetch_array($result)))

 No?


 If I say ...

 0 == False

 does that help?



 Without running the 2 stupid scripts  below, what output should you get?

 ?php while($pos = strpos('abc', 'a')) { echo 'a';} ?

 and

 ?php while($pos = strpos('abc', 'z')) { echo 'z';} ?

 Clearly, they should be different, yes?

 Unfortunately, they won't be.

 The first call returns 0 and the second returns False.

 And as 0 == False, the while() does not loop.

 But ...

 ?php while(False !== ($pos = strpos('abc', 'a'))) { echo 'a';} ?

 and

 ?php while(False !== ($pos = strpos('abc', 'z'))) { echo 'z';} ?

 now operate correctly. The first one runs forever, printing a's and
 the second one quits straight away.

 By always using ...

 while(False !== ($var = function($param)))

 you can clearly differentiate between functions that return false to
 indicate failure and 0 to indicate a position or actual value.

 Regards,

 Richard.





 --
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling



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