Re: [PHP] Re: Unit Testing

2009-04-29 Thread Darren Karstens
You are right, when doing unit tests you only want to test the functionality
of the current class and so if there are errors its easier to track down
which class is causing the problem.

I personally use an api called SimpleTest for my php testing and what you
can do with this is create Mock objects for substituting the objects that
you dont need to test. A Mock object is basically a clone of a classes
structure which then allows you to do stuff like set the return values of
each function or perform tests on the parameters passed to each function.
Ive not used PHPUnit so im not sure if you can do something similar.


On Mon, Apr 27, 2009 at 7:20 PM, Philip Thompson wrote:

> On Apr 27, 2009, at 11:38 AM, Simon wrote:
>
>  As a programmer, i always test what I'm coding as i code it (mostly to
>> make sure i dont include typos), but i feel it is best to make proper
>> testing once the component is ready and working fine.  If your project
>> is large, it might be a good idea to break it in several 'modules' or
>> section if possible and treat each of them as separate projects
>> (testing would be done on a module once this one is ready).
>>
>> You may be interested in looking for information on the net on 'IT
>> project management' which usually describe when is the best time to
>> test according to a certain structure...
>>
>> Simon
>>
>> On Mon, Apr 27, 2009 at 12:16 PM, Nathan Rixham 
>> wrote:
>>
>>> Philip Thompson wrote:
>>>

 Hi. I did some searching in the archives, but didn't quite find what I
 was
 looking for. Maybe a few of you can assist me...

 We have an application that's currently in production, but we're
 constantly modifying/upgrading it. We did not do unit testing early on
 because of the lack of time. Now that some time has opened up, we're
 considering unit testing. My question is. is it reasonable to start
 unit
 testing at this point in time with the application mostly built? Besides
 being really time-consuming, what are the pitfalls of starting unit
 testing
 at this stage?

 Thanks in advance,
 ~Philip

>>>
>>> maybe a useless answer, but, no pitfalls - just do it - I'm always
>>> surprised
>>> by my unit test results, its invaluable and it's never too late to start.
>>>
>>> just think about the next years worth of bugs found by the client not
>>> being
>>> there!
>>>
>>
> A question I have about unit testing. The point is to test individual
> "units"... correct? So, let's say I have this core class which creates
> instances of other classes. Well, if I only want test the core class, I
> don't want to instantiate the other classes... correct? Example:
>
>  // Core.php
> require ('Class1.php');
> require ('Class2.php');
>
> class Core {
>public function __construct () {
>$this->class1 = new Class1 ($this);
>$this->class2 = new Class2 ($this);
>}
> }
>
> // CoreTest.php
> require ('../PHPUnit/Framework.php');
> require ('../includes/Core.php');
>
> class CoreTest extends PHPUnit_Framework_TestCase {
>protected function setUp () {
>$this->core = new Core();
>}
> }
> ?>
>
> So, here, Class1 and Class2 will be instantiated. However, I don't really
> care for them to be so that I can test all the methods in the core class. Is
> this a perfect example of how the original design of the core class is not
> conducive to implementing unit tests? Without rewriting the core class, is
> there a way to test this?
>
> Thanks,
> ~Philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Developing PHP extensions on Windows with VC++, linking problems

2009-04-29 Thread Eugenio Tacchini

At 08.42 29/04/2009 +1000, Chris wrote:

Eugenio Tacchini wrote:

Hi all,
I had to create a PHP extension and I read this article:
http://www.talkphp.com/vbarticles.ph...php-extensions 

Everything worked fine if I keep "Debug" as "Active solution 
configuration" in "Build->Configuration manager"but in this way 
I can only use the extension created on the machine I compiled it.

If I choose "Release" instead of "Debug" I get a fatal error:
dllmain.obj : fatal error LNK1179: invalid or corrupt file: 
duplicate COMDAT '_putwchar'

Can you help me?


Probably a better place to ask is the php-internals list, all of the 
people who develop the c code behind php are on there.


I tried to ask php-win and internals-win without success; I've just 
tried internals also, following your advice.



Eugenio.



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



Re: [PHP] E-Mail Verification - Yes, I know....

2009-04-29 Thread Simon
The SMTP or POP3 protocol (cant remember which) used to support the
ability to connect to the server and verify if a username exists
before delivering the mail.  But this feature was abused and was used
for spamming so it is now disabled on all major servers (it's probably
disabled by default in all servers anyway).

There is no way to verify (without sending an email) if the email will
be received in a mailbox.

Simon

On Tue, Apr 28, 2009 at 11:40 AM, Jay Blanchard  wrote:
> Our company wants to do e-mail verification and does not want to use the
> requests / response method (clicking a link in the e-mail to verify the
> address), which as we all know is the only way you can be truly sure. I
> found this;
>
> http://verify-email.org/
>
> Which seems to be the next best deal and it is written in PHP. Has
> anyone used this? Is anyone doing something similar? How do you handle
> errors? I know that some domains will not accept these requests.
>
> I think that this method would really work for us and cut down on the
> bogus e-mail addresses we're receiving though. Thoughts?
>
> --
> 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: E-Mail Verification - Yes, I know....

2009-04-29 Thread Al



Jay Blanchard wrote:

Our company wants to do e-mail verification and does not want to use the
requests / response method (clicking a link in the e-mail to verify the
address), which as we all know is the only way you can be truly sure. I
found this;

http://verify-email.org/

Which seems to be the next best deal and it is written in PHP. Has
anyone used this? Is anyone doing something similar? How do you handle
errors? I know that some domains will not accept these requests.

I think that this method would really work for us and cut down on the
bogus e-mail addresses we're receiving though. Thoughts?


Use login smtp with authenticate

Include Domain Keys and SPF in your message header. Many incoming mail servers use them to verify 
mail. I've not had one email rejected since using them.


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



RE: [PHP] E-Mail Verification - Yes, I know....

2009-04-29 Thread Bob McConnell
From: Simon
> 
> There is no way to verify (without sending an email) if the email will
> be received in a mailbox.

Even that is not a valid test. Most spam filters will discard messages
silently, that is without notifying either sender or recipient. So the
only real verification is when you receive an actual reply from the
recipient.

Bob McConnell

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



[PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Matt Neimeyer
I have a function that currently takes a boolean value as a parameter.
But now I want to expand it to 3 options...  So if I have...

function doFooBar($doFoo = false)
   {
   if($doFoo)
  { echo "Did Foo"; }
   else
  { echo "Did Bar"; }
   }

Is it as "simple" as changing it like follows to avoid having to
change existing code that won't use the new values.

function doFooBar($doFoo = 0)
   {
   if($doFoo == 2)
  { echo "Did Baz"; }
   else if($doFoo == 1)
  { echo "Did Foo"; }
   else
  { echo "Did Bar"; }
   }

Something about that disturbs me. Perhaps because any time I think "Oh
it will be as simple as..." it usually isn't.

Thanks in advance!

Matt

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



[PHP] Re: Boolean Parameter to 3 Options?

2009-04-29 Thread Jo�o C�ndido de Souza Neto
Why not this:

function doFooBar($doFoo = 0)
   {
   switch ($doFoo) {
   case 2:
echo "Did Baz";
break;
   case 1:
echo "Did Foo";
break;
default:
echo "Did Bar";
break;
}
}

I think in this way you can avoid future problems in case you need to add 
other options in this param.

Hope helps.


"Matt Neimeyer"  escreveu na mensagem 
news:9077339e0904290942y542c7978neb1cd92af5656...@mail.gmail.com...
>I have a function that currently takes a boolean value as a parameter.
> But now I want to expand it to 3 options...  So if I have...
>
> function doFooBar($doFoo = false)
>   {
>   if($doFoo)
>  { echo "Did Foo"; }
>   else
>  { echo "Did Bar"; }
>   }
>
> Is it as "simple" as changing it like follows to avoid having to
> change existing code that won't use the new values.
>
> function doFooBar($doFoo = 0)
>   {
>   if($doFoo == 2)
>  { echo "Did Baz"; }
>   else if($doFoo == 1)
>  { echo "Did Foo"; }
>   else
>  { echo "Did Bar"; }
>   }
>
> Something about that disturbs me. Perhaps because any time I think "Oh
> it will be as simple as..." it usually isn't.
>
> Thanks in advance!
>
> Matt 



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



[PHP] Programming Question

2009-04-29 Thread David Stoltz
Hi Folks,

I'm a PHP newbie - but this question really isn't about PHP per se',
it's more about programming in general, and how to do something...

I'm redesigning an ASP site with Dreamweaver CS4, so I'll be sticking to
using ASP technology

The site will use horizontal navigation for the MAIN MENU which will be
static, but each page therein will have a vertical sub menu, probably
with 2-3 levels deep - which will need to be dynamic.

I'm trying to figure out a good way to organize and maintain the
submenus. I need each page to "know where it is" so the breadcrumb trail
can be accurate and dynamic. The page/menu will also need to know how to
display the correct submenu/level.hopefully this all can be
dynamic

I also want to avoid query string parameters, such as
page.asp?menu=1&submenu=3 type stuff.

My current thought is to use URL rewriting and a database - but I'm not
sure if this is the best route

Does anyone have any suggestions? HELP!

Thanks!

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



Re: [PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Philip Thompson

On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:


I have a function that currently takes a boolean value as a parameter.
But now I want to expand it to 3 options...  So if I have...

function doFooBar($doFoo = false)
  {
  if($doFoo)
 { echo "Did Foo"; }
  else
 { echo "Did Bar"; }
  }

Is it as "simple" as changing it like follows to avoid having to
change existing code that won't use the new values.

function doFooBar($doFoo = 0)
  {
  if($doFoo == 2)
 { echo "Did Baz"; }
  else if($doFoo == 1)
 { echo "Did Foo"; }
  else
 { echo "Did Bar"; }
  }

Something about that disturbs me. Perhaps because any time I think "Oh
it will be as simple as..." it usually isn't.

Thanks in advance!

Matt


Unless you're doing a strict comparison (===), it probably won't make  
a lot of difference. However, if you sent "true" to the function, I  
believe it will reach the last else condition. You may revisit all the  
locations you call it and update them appropriately.


Those are my initial thoughts

~Philip


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



Re: [PHP] Programming Question

2009-04-29 Thread Kyle Smith

David Stoltz wrote:

Hi Folks,

I'm a PHP newbie - but this question really isn't about PHP per se',
it's more about programming in general, and how to do something...

I'm redesigning an ASP site with Dreamweaver CS4, so I'll be sticking to
using ASP technology

The site will use horizontal navigation for the MAIN MENU which will be
static, but each page therein will have a vertical sub menu, probably
with 2-3 levels deep - which will need to be dynamic.

I'm trying to figure out a good way to organize and maintain the
submenus. I need each page to "know where it is" so the breadcrumb trail
can be accurate and dynamic. The page/menu will also need to know how to
display the correct submenu/level.hopefully this all can be
dynamic

I also want to avoid query string parameters, such as
page.asp?menu=1&submenu=3 type stuff.

My current thought is to use URL rewriting and a database - but I'm not
sure if this is the best route

Does anyone have any suggestions? HELP!

Thanks
At a very basic level I think a database is overkill.  I would write 
some sort of include for the top most menu, that includes a function to 
generate the sub menus and a breadcrumb trail.  This is psuedo-code, but 
here's the idea:


// Include top menu and some functions.
include('menu-lib.php');
// Build sub-menu, using my location.
echo build_sub_menu('Contact', 'Sales " Marketing');

This way you can maintain all the menu/breadcrumb/etc in one file, and 
have the information you need in each page to generate it.


HTH,
- Kyle



Re: [PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Shawn McKenzie
Philip Thompson wrote:
> On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:
> 
>> I have a function that currently takes a boolean value as a parameter.
>> But now I want to expand it to 3 options...  So if I have...
>>
>> function doFooBar($doFoo = false)
>>   {
>>   if($doFoo)
>>  { echo "Did Foo"; }
>>   else
>>  { echo "Did Bar"; }
>>   }
>>
>> Is it as "simple" as changing it like follows to avoid having to
>> change existing code that won't use the new values.
>>
>> function doFooBar($doFoo = 0)
>>   {
>>   if($doFoo == 2)
>>  { echo "Did Baz"; }
>>   else if($doFoo == 1)
>>  { echo "Did Foo"; }
>>   else
>>  { echo "Did Bar"; }
>>   }
>>
>> Something about that disturbs me. Perhaps because any time I think "Oh
>> it will be as simple as..." it usually isn't.
>>
>> Thanks in advance!
>>
>> Matt
> 
> Unless you're doing a strict comparison (===), it probably won't make a
> lot of difference. However, if you sent "true" to the function, I
> believe it will reach the last else condition. You may revisit all the
> locations you call it and update them appropriately.
> 
> Those are my initial thoughts
> 
> ~Philip
> 

No, true will match the first condition.  If you're using true and false
now and just want to add a second option then continue using true/false.
 Don't mix and match.  1 == true and 2 == true.

function doFooBar($doFoo = false)
{
   if($doFoo === 2) {
//something
   }
   elseif($doFoo === true) {
//something true
   }
   elseif($doFoo === false) {
//something false
   }
}


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

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



Re: [PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Matt Neimeyer
On Wed, Apr 29, 2009 at 1:30 PM, Shawn McKenzie  wrote:
> Philip Thompson wrote:
>> On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:
>>
>>> I have a function that currently takes a boolean value as a parameter.
>>> But now I want to expand it to 3 options...  So if I have...
>>>
>>> function doFooBar($doFoo = false)
>>>   {
>>>   if($doFoo)
>>>  { echo "Did Foo"; }
>>>   else
>>>  { echo "Did Bar"; }
>>>   }
>>>
>>> Is it as "simple" as changing it like follows to avoid having to
>>> change existing code that won't use the new values.
>>>
>>> function doFooBar($doFoo = 0)
>>>   {
>>>   if($doFoo == 2)
>>>  { echo "Did Baz"; }
>>>   else if($doFoo == 1)
>>>  { echo "Did Foo"; }
>>>   else
>>>  { echo "Did Bar"; }
>>>   }
>>>
>>> Something about that disturbs me. Perhaps because any time I think "Oh
>>> it will be as simple as..." it usually isn't.
>>>
>>> Thanks in advance!
>>>
>>> Matt
>>
>> Unless you're doing a strict comparison (===), it probably won't make a
>> lot of difference. However, if you sent "true" to the function, I
>> believe it will reach the last else condition. You may revisit all the
>> locations you call it and update them appropriately.
>>
>> Those are my initial thoughts
>>
>> ~Philip
>>
>
> No, true will match the first condition.  If you're using true and false
> now and just want to add a second option then continue using true/false.
>  Don't mix and match.  1 == true and 2 == true.
>
> function doFooBar($doFoo = false)
> {
>   if($doFoo === 2) {
>//something
>   }
>   elseif($doFoo === true) {
>//something true
>   }
>   elseif($doFoo === false) {
>//something false
>   }
> }
>

Ah. I somehow missed the direction of the typecasting. Not that the
documentation isn't completely explicit on the matter but for some
reason I was thinking that the bool got cast to 1 or 0... not that the
string/number got cast to a bool (following the standards there).

Good to know.

Thanks

Matt

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



Re: [PHP] Re: $_session/$_cookie trouble

2009-04-29 Thread Igor Escobar
A few days ago i had a problem similar to their and it was a problem with
files with BOM signature... maybe its your case.


Regards,
Igor Escobar
Systems Analyst & Interface Designer

--

Personal Blog
~ blog.igorescobar.com
Online Portifolio
~ www.igorescobar.com
Twitter
~ @igorescobar





On Tue, Apr 28, 2009 at 11:00 PM, Gary  wrote:

> Ok, working code.  I'm sure there is some left over code that is not
> actually working, but I have been playing frankenstein all day. Basically a
> vistor fills in 3 (only two set so far) inputs to see if they qualify for a
> rebate.  If they do, they can go on to file two to submit their
> information.
>
> This is my first project using $_cookie or $_session.  I have done an
> exercise or two in lessons using them, but this is my first attempt from
> scratch.
>
> File1 of 2
>  session_start();
> ?>
>
>  $_SESSION=array('$sale_value', 'assess_value');
>
>
> $sale_value=$_POST['sale'];
> $assess_value=$_POST['assess'];
>
> $mil_rate=.03965;
> $ratio=.51;
>
> $present_tax=($assess_value) * ($mil_rate);
> $correct_tax=($sale_value)*($ratio)*($mil_rate);
> $savings=($present_tax)-($correct_tax);
>
> if ($savings > 0.00){
> echo 'Yes, Your property appears to
> qualify!';
> }
> if ($savings < 0.00){
> echo 'NO, Your property does not appear to qualify.
> ';
> }
> echo 'According to the information you have entered';?>
>  echo "You believe your home would today sell for
> $".number_format($sale_value)."";
> echo "Your current tax assessment is $".number_format($assess_value)." />";
> echo 'You live in ';
> echo 'According to preliminary calculations';
> echo "You are currently paying now  $".number_format($present_tax, 2)." />";
> echo "According to the information you have submitted, your taxes should be
> $ ".number_format($correct_tax, 2)."";
> ?>
>  if ($savings > 0.00){
> echo "According to our preliminary calculations, a successful assessment
> appeal could save you annually on your current real estate taxes. $
> ".number_format($savings, 2)." ";
> }
> if ($savings < 0.00){
> echo 'It does not appear that an appeal would be successful in saving you
> money this year. If property values in your area continue to decline, you
> may wish to revisit the issue next year.';
> }
>
> $_SESSION['sale_value'] ='$sale_value';
> $_SESSION['assess_value'] ='$assess_value';
>
> ?>
> If you feel you have entered
> incorrect information, hit your browsers back button to re-calculate with
> the new information
> Important
> Notice!
> This DOES
> NOT
> constitute a legal opinion by ! No information has been
> submitted.
> In order to proceed with an assessment appeal, you must contact my
> office
> that we may verify all pertinent information regarding your a real estate
> assessment appeal case
>
>  To submit this information to , please complete the following form.
>
> 
> First Name 
> Last Name 
> Property Street Address  
> Town or City 
> Zip Code 
> County 
> Phone Number 
> E-Mail Address 
> 
> 
> 
>
> File 2
>
> 
> ?>
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
> 
> Untitled Document
> 
>
> 
>  $fname=STRIPSLASHES($_POST['fname']);
> $lname=STRIPSLASHES($_POST['lname']);
> $street=STRIPSLASHES($_POST['street']);
> $town=STRIPSLASHES($_POST['town']);
> $zip=STRIPSLASHES($_POST['zip']);
> $county=STRIPSLASHES($_POST['county']);
> $phone=STRIPSLASHES($_POST['phone']);
> $email=STRIPSLASHES($_POST['email']);
> $assess_value=$_COOKIE['assess_value'];
> $sale_value=$_COOKIE['sale_value'];
>
>
> echo "Thank you $fname for your submission!";
> echo "You have submitted the following information.";
> echo "Name:$fname  $lname";
> echo "Address:$street $town  $zip";
> echo "Phone Number: $phone";
> echo "E-Mail Address: $email";
> echo "You believe your home would sell for $"; echo
> $_COOKIE['sale_cookie'];
> ?> echo "Your assessment value is $"; echo $_COOKIE['assess_cookie'];?> /> echo "You live in $county";
>
>
>
>
>
> ?>
> 
> 
>
>
>
> "Lists"  wrote in message news:49f790ed.5040...@euca.us...
> > Andrew Hucks wrote:
> >> $sale_value would have worked if it hadn't been in single quotes, I
> >> believe. (Assuming it was populated.).
> >
> > Which it wasn't.. ;-) according to Gary's last post. He assigned it now
> > with 'sale'.. however, I think it should rather be in double quotes
> > ("sale") if he wants to get the posted value.
> >
> > echo $sale_value;
> >
> > now works because sale_value has been assigned a value.
> >
> > But:
> > echo $_COOKIE['sale_cookie'];
> >
> > I would guess will still not work.. until landing on the
> > next page, or reloading the first page.
> >
> >
> >  When you put it in quotes, you
> >> were making the cookie's value a string instead of a variable. So, the
> >> value would actually have literally been $sale_value, rather than the
> >> value for that variable. It is working with $_POST['sale'] because
> >> there are no single quotes. :-p.
> >
> >
> > Gary, if you want to post your "working" code, we

[PHP] file_get_contents doesn't work on one particular server

2009-04-29 Thread Brian Dunning
Howdy all - We have a production server that runs our script fine.  
We're setting up a test server, and this particular script returns a  
length of zero:


$ctx = stream_context_create(array('http' => array('timeout' =>  
1200))); // 20 minutes per file

$contents = file_get_contents($full_url, 0, $ctx);

You can paste the $full_url into a browser and it works fine (it's  
always a PDF document). It works fine with the same variables on the  
production server. Is there some configuration option that we've  
missed that's preventing it from working? Note that this is all https,  
and I did notice this difference in the phpinfo() but don't know if  
it's relevant:


Production server: PHP 5.2.6
Registered PHP streams: php, file, data, http, ftp, compress.zlib,  
compress.bzip2, https, ftps, zip


Test server: PHP 5.2.9-2
Registered PHP streams: php, file, data, http, ftp, compress.zlib



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



[PHP] Static and/or Dynamic site scraping using PHP

2009-04-29 Thread 9el
I just got a project to do on PHP of scraping the body items from
static sites or just html sites.
Could you experts please suggest me some quick resources?

I have to make an WP plugin with the data as well.

Regards

Lenin

www.twitter.com/nine_L

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



Re: [PHP] utf-8 ?

2009-04-29 Thread Reese

Tom Worster wrote:

On 4/28/09 4:05 PM, "Reese"  wrote:


Granted, this isn't a PHP question but I'm curious, how does UTF-8 solve
this display issue?


if we're talking about web browsers, they are quite good at automatically
choosing fonts that can display the unicode characters it finds in a page.


Right, and I figured out the bit that was confusing me earlier: years
ago, I read that some encodings such as “ and ” (curly
quotes) should not be used, that “ and ” should be used
instead. I misremembered that, when I looked at the utf-8 charset here:

http://www.columbia.edu/kermit/utf8-t1.html

I stand apprised and enlightened. I found the encodings for letters G
with breve, S with cedilla, and lower case I w/out the dot, too.

Reese




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



[PHP] Re: file_get_contents doesn't work on one particular server

2009-04-29 Thread Shawn McKenzie
Brian Dunning wrote:
> Howdy all - We have a production server that runs our script fine. We're
> setting up a test server, and this particular script returns a length of
> zero:
> 
> $ctx = stream_context_create(array('http' => array('timeout' => 1200)));
> // 20 minutes per file
> $contents = file_get_contents($full_url, 0, $ctx);
> 
> You can paste the $full_url into a browser and it works fine (it's
> always a PDF document). It works fine with the same variables on the
> production server. Is there some configuration option that we've missed
> that's preventing it from working? Note that this is all https, and I
> did notice this difference in the phpinfo() but don't know if it's
> relevant:
> 
> Production server: PHP 5.2.6
> Registered PHP streams: php, file, data, http, ftp, compress.zlib,
> compress.bzip2, https, ftps, zip
> 
> Test server: PHP 5.2.9-2
> Registered PHP streams: php, file, data, http, ftp, compress.zlib
> 
> 

Most likely allow_url_fopen = Off in the test server php.ini.  If you
had error reporting on it would tell you.

-- 
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: file_get_contents doesn't work on one particular server

2009-04-29 Thread Shawn McKenzie
Shawn McKenzie wrote:
> Brian Dunning wrote:
>> Howdy all - We have a production server that runs our script fine. We're
>> setting up a test server, and this particular script returns a length of
>> zero:
>>
>> $ctx = stream_context_create(array('http' => array('timeout' => 1200)));
>> // 20 minutes per file
>> $contents = file_get_contents($full_url, 0, $ctx);
>>
>> You can paste the $full_url into a browser and it works fine (it's
>> always a PDF document). It works fine with the same variables on the
>> production server. Is there some configuration option that we've missed
>> that's preventing it from working? Note that this is all https, and I
>> did notice this difference in the phpinfo() but don't know if it's
>> relevant:
>>
>> Production server: PHP 5.2.6
>> Registered PHP streams: php, file, data, http, ftp, compress.zlib,
>> compress.bzip2, https, ftps, zip
>>
>> Test server: PHP 5.2.9-2
>> Registered PHP streams: php, file, data, http, ftp, compress.zlib
>>
>>
> 
> Most likely allow_url_fopen = Off in the test server php.ini.  If you
> had error reporting on it would tell you.
> 

Sorry, didn't pay attention to the registered streams :-(

You need to install a PHP package with ssl or compile it with
--with-openssl.

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

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



[PHP] DateInterval

2009-04-29 Thread MIke Alaimo

Hello,

I would like to know how to correctly use DateInterval::format().  The 
documentation is unclear.


Also, I am willing to write some documentation for the DateInterval and 
DatePeriod if no one has taken the task.


Thanks for the help.

Mike

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



Re: [PHP] DateInterval

2009-04-29 Thread Raymond Irving
Sounds great Mike.

I personally would also like to see standard date/time functions (strtotime, 
strftime, date, etc) support dates greater than 2038. I think this can be done 
internally by parsing the datetime value swith the DateInterval object and 
retuning the results to the standard functions.

Best regards,
__
Raymond Irving


--- On Wed, 4/29/09, MIke Alaimo  wrote:

From: MIke Alaimo 
Subject: [PHP] DateInterval
To: php-general@lists.php.net
Date: Wednesday, April 29, 2009, 8:53 PM

Hello,

I would like to know how to correctly use DateInterval::format().  The 
documentation is unclear.

Also, I am willing to write some documentation for the DateInterval and 
DatePeriod if no one has taken the task.

Thanks for the help.

Mike

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



[PHP] Two very useful PHP functions

2009-04-29 Thread Raymond Irving
Hello,

Every so often I have to be using the isset() function to check if a variable 
exists. It would be useful to have something like an ifset() function

Instead of doing this

$v = isset($input) ? $input : $default;

we can do this

$v = ifset($input,$default); 
// returns $input if it exists otherwise it will return $default

We could also do the same for the empty() function. So instead of doing this

$v = empty($input) ? $default : $input;

we can do this

$v = ifempty($input,$default);
// returns $input if it is not empty otherwise it will return $default

What do you think? Can they make it into 5.3?


Best regards
__
Raymond Irving



Re: [PHP] DateInterval

2009-04-29 Thread MIke Alaimo

Here is something i'd like to point out with DateInterval.

$dInt = 'PT4320S';
$d = new DateInterval($dInt);
var_dump($d);
$dz = new DateTimeZone(UTC);
$dt = new DateTime('now',$dz);
$dt->add($d);
var_dump($dt->format(DATE_ATOM));

It appears that running this code fails when it seems like it should work.

$dInt = 'PT43200S';
$d = new DateInterval($dInt);
var_dump($d);
$dz = new DateTimeZone(UTC);
$dt = new DateTime('now',$dz);
$dt->add($d);
var_dump($dt->format(DATE_ATOM));


Please note the first value in $dInt should be 72 minutes, while the 
later should be 720 minutes or half of a day


The PT12H  interval seems to work fine.

$dInt = 'PT12H';
$d = new DateInterval($dInt);
var_dump($d);
$dz = new DateTimeZone(UTC);
$dt = new DateTime('now',$dz);
$dt->add($d);
var_dump($dt->format(DATE_ATOM));


Raymond, have you tried using DateTime::modify?  It appears to work like 
strtotime.

also DateTime::format works like date.  At least as far as I can tell.


Mike

Raymond Irving wrote:

Sounds great Mike.

I personally would also like to see standard date/time functions 
(strtotime, strftime, date, etc) support dates greater than 2038. I 
think this can be done internally by parsing the datetime value swith 
the DateInterval object and retuning the results to the standard 
functions.


Best regards,
__
Raymond Irving


--- On *Wed, 4/29/09, MIke Alaimo //* wrote:


From: MIke Alaimo 
Subject: [PHP] DateInterval
To: php-general@lists.php.net
Date: Wednesday, April 29, 2009, 8:53 PM

Hello,

I would like to know how to correctly use DateInterval::format(). 
The documentation is unclear.


Also, I am willing to write some documentation for the
DateInterval and DatePeriod if no one has taken the task.

Thanks for the help.

Mike

-- 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] DateInterval

2009-04-29 Thread Raymond Irving



--- On Wed, 4/29/09, MIke Alaimo  wrote:
> 
> Raymond, have you tried using DateTime::modify?  It
> appears to work like strtotime.
> also DateTime::format works like date.  At least as
> far as I can tell.
> 


From the little documentation that I've seen it appears that it's similar to 
strtotime and date but it would be very good if the PHP devs could make 
strtotime() and date() become wrappers for DateTime::modify and 
DateTime::format. This way we dont hae to modify our code when moving to a 
version of PHP that supports the new DateTime class.

__
Raymond Irving

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