[PHP] Bug #52782: DOMDocument subclass forgotten using ->ownerDocument after closure

2010-10-05 Thread Jan Moesen
(I filed bug #52782 about a month ago, but have not received any reply. 
I am posting here to try and get some feedback on it.)


We have custom XML document and element classes that extend the original 
DOMDocument and DOMElement classes for convenience. There is a class 
that uses an instance of XmlElement obtained via a callback specified at 
construction time. That XmlElement works fine and stays that way. 
However, when we get its ownerDocument outside of the closure, the 
result is not an XmlDocument but a DOMDocument. I cannot see a single 
reason why.


I tried several options, and it only seems to happen with that closure. 
I have checked versions 5.3.1, 5.3.2, 5.3.3 and now the latest 5.3.4 
snapshot compiled with './configure && make'.


More details and a test case: http://bugs.php.net/bug.php?id=52782

Jan

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



[PHP] Continuance of the struggle (trying to understand)

2010-10-05 Thread Col Day

Hi all,

After my escapades with the real basics and realizing my laptop wasn't 
logged on as Administrator, I now am trying to work out why this script 
works sometimes but not others.


   
   
   PHP Test
   
   
   This is an HTML line
   This is a PHP line";
  phpinfo();
   ?>
   
   

If I save this as phptest.php and open IE pointing it to 
localhost/phptest.php it works fine. Get both lines of text followed by the 
pages of gumpf about php.


However if I paste this into a



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



[PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Col Day


""Col Day""  wrote in message 
news:23.81.45586.2820b...@pb1.pair.com...

Hi all,

After my escapades with the real basics and realizing my laptop wasn't 
logged on as Administrator, I now am trying to work out why this script 
works sometimes but not others.


   
   
   PHP Test
   
   
   This is an HTML line
   This is a PHP line";
  phpinfo();
   ?>
   
   

If I save this as phptest.php and open IE pointing it to 
localhost/phptest.php it works fine. Get both lines of text followed by 
the pages of gumpf about php.


However if I paste this into a




That was weird!

I was saying, If I paste this into a webpage I only get the "HTML" line as 
before.


Anyone have any ideas?

PHP is obviously working as is apache. Just don't understand why they don't 
show up in web pages.


Cheers again all! 



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



Re: [PHP] file_get_contents() failing on CentOS.

2010-10-05 Thread Richard Quadling
The issue _WAS_ the firewall.

All sorted.

Thank you.

-- 
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] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Shreyas Agasthya
Col,

Can you let us know what exactly you see when you say
http://localhost:/phptest.php
?


Regards,
Shreyas

On Tue, Oct 5, 2010 at 4:20 PM, Col Day  wrote:

>
> ""Col Day""  wrote in message
> news:23.81.45586.2820b...@pb1.pair.com...
>
>  Hi all,
>>
>> After my escapades with the real basics and realizing my laptop wasn't
>> logged on as Administrator, I now am trying to work out why this script
>> works sometimes but not others.
>>
>>   
>>   
>>   PHP Test
>>   
>>   
>>   This is an HTML line
>>   >  echo "This is a PHP line";
>>  phpinfo();
>>   ?>
>>   
>>   
>>
>> If I save this as phptest.php and open IE pointing it to
>> localhost/phptest.php it works fine. Get both lines of text followed by the
>> pages of gumpf about php.
>>
>> However if I paste this into a
>>
>>
>>
> That was weird!
>
> I was saying, If I paste this into a webpage I only get the "HTML" line as
> before.
>
> Anyone have any ideas?
>
> PHP is obviously working as is apache. Just don't understand why they don't
> show up in web pages.
>
> Cheers again all!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
Shreyas Agasthya


Re: [PHP] Filesystem path creation function

2010-10-05 Thread Richard Quadling
On 5 October 2010 09:07, Gary  wrote:
> Does such a thing exist in php? My searches have lead nowhere.
>
> What I am looking for is a function which you would pass two parts of a
> path to (which might be a directory and a filename, say) and it would
> return a string containing the parameters separate by the correct number
> of path separators according to the current OS.
>
> For example:
>
>  $d = 'foo';
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> Would result in 'foo\bar' (Windows), 'foo/bar' (*n*x).
>
> And
>  $d = 'foo/'; // note the trailing slash
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> on *n*x would also result in 'foo/bar' (i.e. the path would only contain
> one "/").
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Yep.

function createPathString($d, $f){return $d. DIRECTORY_SEPARATOR . $f;}




-- 
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] Filesystem path creation function

2010-10-05 Thread Richard Quadling
On 5 October 2010 09:07, Gary  wrote:
> Does such a thing exist in php? My searches have lead nowhere.
>
> What I am looking for is a function which you would pass two parts of a
> path to (which might be a directory and a filename, say) and it would
> return a string containing the parameters separate by the correct number
> of path separators according to the current OS.
>
> For example:
>
>  $d = 'foo';
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> Would result in 'foo\bar' (Windows), 'foo/bar' (*n*x).
>
> And
>  $d = 'foo/'; // note the trailing slash
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> on *n*x would also result in 'foo/bar' (i.e. the path would only contain
> one "/").
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

http://www.php.net/manual/en/dir.constants.php

-- 
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] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Col Day

Hi Shreyas,

Ok, as far as I can tell the script should show "This is an HTML line" 
reflecting that I am seeing the HTML part of the script followed by "This is 
a PHP line" to show that PHP is installed and working fine.


If I view the script directly in IE by going to http://localhost/phptest.php 
I get the output:


This is an HTML line

This is a PHP line

followed by a large and detailed list of the PHP install which includes 
things like compiler language etc.


If I paste the script into a web page then all that is displayed is

This is an HTML line.

Nothing else whatsoever.

I am fairly confused. I've tried a couple of different web page creators 
(Webplus 10 and Web page maker) and get the same result.


Sorry if I sound extremely naive but it's bugging me now and I want to 
understand.


Cheers

"Shreyas Agasthya"  wrote in message 
news:aanlkti=4ke1stf8tan7+ecjo-ux5cj=t9-0qctcfk...@mail.gmail.com...

Col,

Can you let us know what exactly you see when you say
http://localhost:/phptest.php
?


Regards,
Shreyas

On Tue, Oct 5, 2010 at 4:20 PM, Col Day  wrote:



""Col Day""  wrote in message
news:23.81.45586.2820b...@pb1.pair.com...

 Hi all,


After my escapades with the real basics and realizing my laptop wasn't
logged on as Administrator, I now am trying to work out why this script
works sometimes but not others.

  
  
  PHP Test
  
  
  This is an HTML line
  This is a PHP line";
 phpinfo();
  ?>
  
  

If I save this as phptest.php and open IE pointing it to
localhost/phptest.php it works fine. Get both lines of text followed by 
the

pages of gumpf about php.

However if I paste this into a




That was weird!

I was saying, If I paste this into a webpage I only get the "HTML" line 
as

before.

Anyone have any ideas?

PHP is obviously working as is apache. Just don't understand why they 
don't

show up in web pages.

Cheers again all!

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





--
Regards,
Shreyas Agasthya




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



[PHP] Re: New to PHP and struggling with the basics

2010-10-05 Thread Col Day

Thanks Gary!

Nice to know I'm not the only one who has struggled with the Basics. 
Hopefully I can get my brain around it sometime soon.


Cheers

Col.

"Gary"  wrote in message 
news:i8f1r9$j4...@dough.gmane.org...

Col Day wrote:

Yes I did install apache then php, however I tried to follow the
instructions in the Dummies book (what does it make me if I can't follow
the dummies book?) but to no avail.


Don't know what it makes you, but I remember trying to install Apache &
PHP separately a couple of years ago. The frustration of mismatching
versions (Apache only supporting PHP version something, PHP only playing
well with Apache version something-else) was... rather high. Head met
keyboard several times.




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



[PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Col Day

LOL!

This is WITH xammp!!



"Gary"  wrote in message 
news:i8f26m$j4...@dough.gmane.org...

Col Day wrote:

""Col Day""  wrote in message
news:23.81.45586.2820b...@pb1.pair.com...

   
   
   PHP Test
   
   
   This is an HTML line

  

   This is a PHP line";
  phpinfo();
   ?>
   
   



If I paste this into a webpage I only get the "HTML" line as before.


What do you mean, "webpage"? foo.php, for example, or foo.html? If the
latter then I am guessing your Apache will serve the page purely as
html, and it will never be processed by php. If the former then check
that Apache is configured to run php files through php before serving
them (must admit, I'm not sure how to do that, it depends on your Apache
and PHP). Or, really, just install xampp, it's by far the easiest way
and will avoid all the problems associated with configuring two rather
complex pieces of software.




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



RES: [PHP] Connecting to MySql with PHP

2010-10-05 Thread Alejandro Michelin Salomon
Sueandant :

Goto your my.ini file
In my case located in C:\Arquivos de programas\MySQL\MySQL Server 5.1

Search is this configuration option is enabled => skip-networking
And comment to enabled listen on a TCP/IP port. Default port 3306

Or 
Put => enable-named-pipe to enable named pipes

Alejandro M.S.
-Mensagem original-
De: sueandant [mailto:hollandsath...@tiscali.co.uk] 
Enviada em: segunda-feira, 4 de outubro de 2010 18:08
Para: php-general@lists.php.net
Assunto: [PHP] Connecting to MySql with PHP

I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1.   My
OS is Vista Home Premium 32 bit with SP2.

MySql works fine from the command prompt, Apache is running and PHP works.
But I cannot access the mysqli classes.   This simple program:



produces this error message:

Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt
failed because the connected party did not (trying to connect via
tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3

Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection
attempt failed because the connected party did not properly respond after a
period of time, or established connection failed because connected host has
failed to respond. in C:\Apache\htdocs\mysqlconnect.php on line 3

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\Apache\htdocs\mysqlconnect.php on line 3

I guess PHP cannot find the mysqli classes.   I've checked the phpinfo()
output and discovered :

  Configuration File (php.ini) Path  C:\Windows  
  Loaded Configuration File  C:\PHP\php.ini  


I don't know if this ok.   I've tried changing the location of the loaded
file to C:\Windows\php.ini, but to no avail, and I don't know how to change
the location of the config file.

I am obviously doing something wrong, but I don't know what.   Can anyone
help?

Ironically, everything worked perfectly before I upgraded to PHP 5.3.3!


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



Re: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Steve Staples
Col:

If i am reading this correctly, then i think you're looking at this all
wrong.

If you're working within some kind of page, stored outside of the
http://localhost served by apache, like say the .php file is on the
desktop... then yeah, you're not going to get the PHP information
displayed.

(tech people bare with me here...)
PHP pages, are "compiled" when called... so you need apache to call php
and translate the PHP code so that if there is any output, it will
display that output.

If you're trying to show a .php file from teh desktop, then apache isn't
handeling this request, and therefor has no idea that there is php code
that has to be compiled, and therefore it will just ignore it.

I am sure that I am goign to get flamed for that, but i think that it
kinda simplifies what apache does for php.

NOW... you can run a php file from the command line, but you're not
going to get the HTML results as you would had you ran if from the
localhost where apache knows what to do with a .php file.

So... long story short, if you want PHP to display the PHP stuff, then
you will need to have it interpreted by apache (or IIS, or whatever your
web server software is) to have it spit back to a web browser client.

Hopefully this makes sense, it is early here, i am just getting into
work :(, and it made sense while i was typing it... but my coffee intake
has not had time to work it's wonderful magic with me yet, so my
thoughts may be scattered.

Steve



On Tue, 2010-10-05 at 12:57 +0100, Col Day wrote:
> LOL!
> 
> This is WITH xammp!!
> 
> 
> 
> "Gary"  wrote in message 
> news:i8f26m$j4...@dough.gmane.org...
> > Col Day wrote:
> >> ""Col Day""  wrote in message
> >> news:23.81.45586.2820b...@pb1.pair.com...
> >>>
> >>>
> >>>PHP Test
> >>>
> >>>
> >>>This is an HTML line
> >   
> >>> >>>   echo "This is a PHP line";
> >>>   phpinfo();
> >>>?>
> >>>
> >>>
> >
> >> If I paste this into a webpage I only get the "HTML" line as before.
> >
> > What do you mean, "webpage"? foo.php, for example, or foo.html? If the
> > latter then I am guessing your Apache will serve the page purely as
> > html, and it will never be processed by php. If the former then check
> > that Apache is configured to run php files through php before serving
> > them (must admit, I'm not sure how to do that, it depends on your Apache
> > and PHP). Or, really, just install xampp, it's by far the easiest way
> > and will avoid all the problems associated with configuring two rather
> > complex pieces of software.
> > 
> 
> 



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



RES: [PHP] Connecting to MySql with PHP

2010-10-05 Thread Alejandro Michelin Salomon
Sueandant :

Reading more carefully your email, and search for this error in the net.
Y find this page
http://coreygilmore.com/blog/2009/11/20/fix-php-5-3-hang-on-windows/

Try this

Alejandro M.S.

-Mensagem original-
De: Alejandro Michelin Salomon [mailto:amichel...@hotmail.com] 
Enviada em: terça-feira, 5 de outubro de 2010 09:01
Para: 'sueandant'
Cc: php-general@lists.php.net
Assunto: RES: [PHP] Connecting to MySql with PHP

Sueandant :

Goto your my.ini file
In my case located in C:\Arquivos de programas\MySQL\MySQL Server 5.1

Search is this configuration option is enabled => skip-networking
And comment to enabled listen on a TCP/IP port. Default port 3306

Or 
Put => enable-named-pipe to enable named pipes

Alejandro M.S.
-Mensagem original-
De: sueandant [mailto:hollandsath...@tiscali.co.uk] 
Enviada em: segunda-feira, 4 de outubro de 2010 18:08
Para: php-general@lists.php.net
Assunto: [PHP] Connecting to MySql with PHP

I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1.   My
OS is Vista Home Premium 32 bit with SP2.

MySql works fine from the command prompt, Apache is running and PHP works.
But I cannot access the mysqli classes.   This simple program:



produces this error message:

Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt
failed because the connected party did not (trying to connect via
tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3

Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection
attempt failed because the connected party did not properly respond after a
period of time, or established connection failed because connected host has
failed to respond. in C:\Apache\htdocs\mysqlconnect.php on line 3

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\Apache\htdocs\mysqlconnect.php on line 3

I guess PHP cannot find the mysqli classes.   I've checked the phpinfo()
output and discovered :

  Configuration File (php.ini) Path  C:\Windows  
  Loaded Configuration File  C:\PHP\php.ini  


I don't know if this ok.   I've tried changing the location of the loaded
file to C:\Windows\php.ini, but to no avail, and I don't know how to change
the location of the config file.

I am obviously doing something wrong, but I don't know what.   Can anyone
help?

Ironically, everything worked perfectly before I upgraded to PHP 5.3.3!


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



Fw: [PHP] Connecting to MySql with PHP

2010-10-05 Thread sueandant

- Original Message - 
From: sueandant 
To: a...@ashleysheridan.co.uk 
Sent: Monday, October 04, 2010 10:29 PM
Subject: Re: [PHP] Connecting to MySql with PHP


Thanks Ash

Where do I find the PHP mysql module?   I have uncommented both the extensions 
php-mysql.dll and php-mysqli.dll; do I need to do more?

Thanks

Tony Holland
  - Original Message - 
  From: a...@ashleysheridan.co.uk 
  To: sueandant ; php-general@lists.php.net 
  Sent: Monday, October 04, 2010 10:21 PM
  Subject: Re: [PHP] Connecting to MySql with PHP


  Have you installed the php mysql module? Basically, it tells php how to 
connect to mysql.

  This question has come up a few times this week, have you tried installing 
something like xampp or easyphp rather than the individual software components: 
Apache, php & mysql.

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

  - Reply message -
  From: "sueandant" 
  Date: Mon, Oct 4, 2010 22:08
  Subject: [PHP] Connecting to MySql with PHP
  To: 

  I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1.   My OS 
is Vista Home Premium 32 bit with SP2.

  MySql works fine from the command prompt, Apache is running and PHP works.   
But I cannot access the mysqli classes.   This simple program:

  

  produces this error message:

  Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt failed 
because the connected party did not (trying to connect via 
tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3

  Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection attempt 
failed because the connected party did not properly respond after a period of 
time, or established connection failed because connected host has failed to 
respond. in C:\Apache\htdocs\mysqlconnect.php on line 3

  Fatal error: Maximum execution time of 30 seconds exceeded in 
C:\Apache\htdocs\mysqlconnect.php on line 3

  I guess PHP cannot find the mysqli classes.   I've checked the phpinfo() 
output and discovered :

   Configuration File (php.ini) Path  C:\Windows  
   Loaded Configuration File  C:\PHP\php.ini  


  I don't know if this ok.   I've tried changing the location of the loaded 
file to C:\Windows\php.ini, but to no avail, and I don't know how to change the 
location of the config file.

  I am obviously doing something wrong, but I don't know what.   Can anyone 
help?

  Ironically, everything worked perfectly before I upgraded to PHP 5.3.3!



Re: Fw: [PHP] Connecting to MySql with PHP

2010-10-05 Thread Steve Staples
On Tue, 2010-10-05 at 13:35 +0100, sueandant wrote:
> - Original Message - 
> From: sueandant 
> To: a...@ashleysheridan.co.uk 
> Sent: Monday, October 04, 2010 10:29 PM
> Subject: Re: [PHP] Connecting to MySql with PHP
> 
> 
> Thanks Ash
> 
> Where do I find the PHP mysql module?   I have uncommented both the 
> extensions php-mysql.dll and php-mysqli.dll; do I need to do more?
> 

Just curious... BUT

Did you restart apache (or your webserver software) ?



> Thanks
> 
> Tony Holland
>   - Original Message - 
>   From: a...@ashleysheridan.co.uk 
>   To: sueandant ; php-general@lists.php.net 
>   Sent: Monday, October 04, 2010 10:21 PM
>   Subject: Re: [PHP] Connecting to MySql with PHP
> 
> 
>   Have you installed the php mysql module? Basically, it tells php how to 
> connect to mysql.
> 
>   This question has come up a few times this week, have you tried installing 
> something like xampp or easyphp rather than the individual software 
> components: Apache, php & mysql.
> 
>   Thanks,
>   Ash
>   http://www.ashleysheridan.co.uk
> 
>   - Reply message -
>   From: "sueandant" 
>   Date: Mon, Oct 4, 2010 22:08
>   Subject: [PHP] Connecting to MySql with PHP
>   To: 
> 
>   I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1.   My 
> OS is Vista Home Premium 32 bit with SP2.
> 
>   MySql works fine from the command prompt, Apache is running and PHP works.  
>  But I cannot access the mysqli classes.   This simple program:
> 
>
>   $mysqli = new mysqli("localhost", "root", "##", "testDB");#I've 
> deliberately obliterated the password
> 
>   if (mysqli_connect_errno()) {
>   printf("Connect failed: %s\n", mysqli_connect_error());
>   exit();
>   } else {
>   printf("Host information: %s\n", mysqli_get_host_info($mysqli));
>   }
>   ?>
> 
>   produces this error message:
> 
>   Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt 
> failed because the connected party did not (trying to connect via 
> tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3
> 
>   Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection 
> attempt failed because the connected party did not properly respond after a 
> period of time, or established connection failed because connected host has 
> failed to respond. in C:\Apache\htdocs\mysqlconnect.php on line 3
> 
>   Fatal error: Maximum execution time of 30 seconds exceeded in 
> C:\Apache\htdocs\mysqlconnect.php on line 3
> 
>   I guess PHP cannot find the mysqli classes.   I've checked the phpinfo() 
> output and discovered :
> 
>Configuration File (php.ini) Path  C:\Windows  
>Loaded Configuration File  C:\PHP\php.ini  
> 
> 
>   I don't know if this ok.   I've tried changing the location of the loaded 
> file to C:\Windows\php.ini, but to no avail, and I don't know how to change 
> the location of the config file.
> 
>   I am obviously doing something wrong, but I don't know what.   Can anyone 
> help?
> 
>   Ironically, everything worked perfectly before I upgraded to PHP 5.3.3!
> 



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



RE: Fw: [PHP] Connecting to MySql with PHP

2010-10-05 Thread Jason
>-Original Message-
>From: Steve Staples [mailto:sstap...@mnsi.net] 
>Sent: 05 October 2010 13:55
>To: php-general
>Subject: Re: Fw: [PHP] Connecting to MySql with PHP
>
>On Tue, 2010-10-05 at 13:35 +0100, sueandant wrote:
>> - Original Message - 
>> From: sueandant 
>> To: a...@ashleysheridan.co.uk 
>> Sent: Monday, October 04, 2010 10:29 PM
>> Subject: Re: [PHP] Connecting to MySql with PHP
>> 
>> 
>> Thanks Ash
>> 
>> Where do I find the PHP mysql module?   I have uncommented both the 
>> extensions php-mysql.dll and php-mysqli.dll; do I need to do more?
>> 
>
>Just curious... BUT
>
>Did you restart apache (or your webserver software) ?
>
>

Also, did you configure the windows firewall to allow connections into the 
MySQL server?

J


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



RE: Fw: [PHP] Connecting to MySql with PHP

2010-10-05 Thread Steve Staples
On Tue, 2010-10-05 at 14:02 +0100, Jason wrote:
> >-Original Message-
> >From: Steve Staples [mailto:sstap...@mnsi.net] 
> >Sent: 05 October 2010 13:55
> >To: php-general
> >Subject: Re: Fw: [PHP] Connecting to MySql with PHP
> >
> >On Tue, 2010-10-05 at 13:35 +0100, sueandant wrote:
> >> - Original Message - 
> >> From: sueandant 
> >> To: a...@ashleysheridan.co.uk 
> >> Sent: Monday, October 04, 2010 10:29 PM
> >> Subject: Re: [PHP] Connecting to MySql with PHP
> >> 
> >> 
> >> Thanks Ash
> >> 
> >> Where do I find the PHP mysql module?   I have uncommented both the 
> >> extensions php-mysql.dll and php-mysqli.dll; do I need to do more?
> >> 
> >
> >Just curious... BUT
> >
> >Did you restart apache (or your webserver software) ?
> >
> >
> 
> Also, did you configure the windows firewall to allow connections into the 
> MySQL server?
> 
> J
> 
> 

Jason:
if you're using it via localhost, does the firewall come into play here?

All:
Also, the BIND-ADDRESS in the my.cnf, it may not be set properly
(usually they say to comment that line out)

Steve.


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



Re: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread chris h
"If I paste the script into a web page"

What do you mean by "paste the script into a web page"?  Can you tell us
exactly what you are doing when you do that?


Chris.



On Tue, Oct 5, 2010 at 7:54 AM, Col Day  wrote:

> Hi Shreyas,
>
> Ok, as far as I can tell the script should show "This is an HTML line"
> reflecting that I am seeing the HTML part of the script followed by "This is
> a PHP line" to show that PHP is installed and working fine.
>
> If I view the script directly in IE by going to
> http://localhost/phptest.php I get the output:
>
>
> This is an HTML line
>
> This is a PHP line
>
> followed by a large and detailed list of the PHP install which includes
> things like compiler language etc.
>
> If I paste the script into a web page then all that is displayed is
>
> This is an HTML line.
>
> Nothing else whatsoever.
>
> I am fairly confused. I've tried a couple of different web page creators
> (Webplus 10 and Web page maker) and get the same result.
>
> Sorry if I sound extremely naive but it's bugging me now and I want to
> understand.
>
> Cheers
>
> "Shreyas Agasthya"  wrote in message
> news:aanlkti=4ke1stf8tan7+ecjo-ux5cj=t9-0qctcfk...@mail.gmail.com...
>
>  Col,
>>
>> Can you let us know what exactly you see when you say
>> http://localhost:/phptest.php
>> ?
>>
>>
>> Regards,
>> Shreyas
>>
>> On Tue, Oct 5, 2010 at 4:20 PM, Col Day  wrote:
>>
>>
>>> ""Col Day""  wrote in message
>>> news:23.81.45586.2820b...@pb1.pair.com...
>>>
>>>  Hi all,
>>>

 After my escapades with the real basics and realizing my laptop wasn't
 logged on as Administrator, I now am trying to work out why this script
 works sometimes but not others.

  
  
  PHP Test
  
  
  This is an HTML line
  >>> echo "This is a PHP line";
 phpinfo();
  ?>
  
  

 If I save this as phptest.php and open IE pointing it to
 localhost/phptest.php it works fine. Get both lines of text followed by
 the
 pages of gumpf about php.

 However if I paste this into a



  That was weird!
>>>
>>> I was saying, If I paste this into a webpage I only get the "HTML" line
>>> as
>>> before.
>>>
>>> Anyone have any ideas?
>>>
>>> PHP is obviously working as is apache. Just don't understand why they
>>> don't
>>> show up in web pages.
>>>
>>> Cheers again all!
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>
>> --
>> Regards,
>> Shreyas Agasthya
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: Fw: [PHP] Connecting to MySql with PHP

2010-10-05 Thread musicdev

Hello,

remember that for windows, you must also copy the library (libmysql.dll) to 
window's system32 directory in addition to un-commenting the 
extension=php_mysql.dll line in php.ini.  Also, just in case, ensure that 
php.ini also has the proper extension directory set, typically c:\php\ext 
but depends on where you installed php.


--
From: "Steve Staples" 
Sent: Tuesday, October 05, 2010 9:08 AM
To: "'php-general'" 
Subject: RE: Fw: [PHP] Connecting to MySql with PHP


On Tue, 2010-10-05 at 14:02 +0100, Jason wrote:

>-Original Message-
>From: Steve Staples [mailto:sstap...@mnsi.net]
>Sent: 05 October 2010 13:55
>To: php-general
>Subject: Re: Fw: [PHP] Connecting to MySql with PHP
>
>On Tue, 2010-10-05 at 13:35 +0100, sueandant wrote:
>> - Original Message - 
>> From: sueandant

>> To: a...@ashleysheridan.co.uk
>> Sent: Monday, October 04, 2010 10:29 PM
>> Subject: Re: [PHP] Connecting to MySql with PHP
>>
>>
>> Thanks Ash
>>
>> Where do I find the PHP mysql module?   I have uncommented both the 
>> extensions php-mysql.dll and php-mysqli.dll; do I need to do more?

>>
>
>Just curious... BUT
>
>Did you restart apache (or your webserver software) ?
>
>

Also, did you configure the windows firewall to allow connections into 
the MySQL server?


J




Jason:
if you're using it via localhost, does the firewall come into play here?

All:
Also, the BIND-ADDRESS in the my.cnf, it may not be set properly
(usually they say to comment that line out)

Steve.


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



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



RE: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Ford, Mike


> -Original Message-
> From: Col Day [mailto:colind...@aol.com]
> Sent: 05 October 2010 12:55
> To: php-general@lists.php.net
> Subject: Re: [PHP] Re: Continuance of the struggle (trying to
> understand)
> 
> Hi Shreyas,
> 
> Ok, as far as I can tell the script should show "This is an HTML
> line"
> reflecting that I am seeing the HTML part of the script followed by
> "This is
> a PHP line" to show that PHP is installed and working fine.
> 
> If I view the script directly in IE by going to
> http://localhost/phptest.php
> I get the output:
> 
> This is an HTML line
> 
> This is a PHP line
> 
> followed by a large and detailed list of the PHP install which
> includes
> things like compiler language etc.
> 
> If I paste the script into a web page then all that is displayed is

What on earth does this mean? http://localhost/phptest.php *is* a web page -- 
especially as you have structured it as PHP within HTML -- so why would you 
want to paste the code anywhere else?

I think your concepts are a little skew-whiff, and you need to explain what it 
is you think you're trying to do in more detail so that we can spot where it is 
that your understanding is wrong.

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



[PHP] i wanna join

2010-10-05 Thread Xuan Huy
-- 
Ngô Xuân Huy


Re: [PHP] file_get_contents() failing on CentOS.

2010-10-05 Thread Adam Richardson
On Tue, Oct 5, 2010 at 6:56 AM, Richard Quadling wrote:

> The issue _WAS_ the firewall.
>
> All sorted.
>
> Thank you.
>
>
Glad he got it working.

Adam

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


[PHP] Re: Is it possible to create a global namespace alias?

2010-10-05 Thread Matt Palermo
I'm assuming there is no way to make a global alias.  Can anyone 
confirm/deny this?




""Matt Palermo""  wrote in message 
news:5e7b8989448b45dbbeeb6fb89b3f3...@rachet...


Is it possible to create a global namespace alias in PHP or does the alias 
have to be defined in EVERY file that I use?  Here is an example:


file:  main.php



file:  index.php



The above code doesn’t work for me.  The namespace alias defined in the 
main.php file isn’t accessible in the index.php file.  Is there a way to 
make the “nsItem” alias a “global” one, so that I don’t have to define it in 
EVERY file that I want to use?


-Matt 



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



Re: [PHP] Re: Is it possible to create a global namespace alias?

2010-10-05 Thread David Harkness
On Tue, Oct 5, 2010 at 8:41 AM, Matt Palermo  wrote:

> I'm assuming there is no way to make a global alias.  Can anyone
> confirm/deny this?
>

I reread the documentation on namespaces, and from what I can tell this is
no way to do it. Each file maintains its own active namespace *at compile
time*. This means you can't even get around it with eval() or including
another script to set it.

I can't say I'm positive someone won't find a way around it, but short of an
extension I don't see one.

David


Re: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread tedd

At 12:54 PM +0100 10/5/10, Col Day wrote:

Hi Shreyas,

Ok, as far as I can tell the script should show "This is an HTML 
line" reflecting that I am seeing the HTML part of the script 
followed by "This is a PHP line" to show that PHP is installed and 
working fine.


Col:

Do this:

1. Create a file and entitle it "index.php" (without quotes)
2. Enter "" (without quotes)
3. Save the file.
4. Upload the file to your host.
5. Open a browser and enter the url (i.e., http://yourdomain.com/index.php)

What do you see?

Cheers,

tedd


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

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



Re: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread tedd

At 1:56 PM -0400 10/5/10, tedd wrote:

At 12:54 PM +0100 10/5/10, Col Day wrote:

Hi Shreyas,

Ok, as far as I can tell the script should show "This is an HTML 
line" reflecting that I am seeing the HTML part of the script 
followed by "This is a PHP line" to show that PHP is installed and 
working fine.


Col:

Do this:

1. Create a file and entitle it "index.php" (without quotes)
2. Enter "" (without quotes)
3. Save the file.
4. Upload the file to your host.
5. Open a browser and enter the url (i.e., http://yourdomain.com/index.php)

What do you see?

Cheers,

tedd



Col:

You don't have to tell what you see, but rather do you see anything?

Cheers,

tedd

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

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



Re: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread Steve Staples
On Tue, 2010-10-05 at 14:32 -0400, tedd wrote:
> At 1:56 PM -0400 10/5/10, tedd wrote:
> >At 12:54 PM +0100 10/5/10, Col Day wrote:
> >>Hi Shreyas,
> >>
> >>Ok, as far as I can tell the script should show "This is an HTML 
> >>line" reflecting that I am seeing the HTML part of the script 
> >>followed by "This is a PHP line" to show that PHP is installed and 
> >>working fine.
> >
> >Col:
> >
> >Do this:
> >
> >1. Create a file and entitle it "index.php" (without quotes)
> >2. Enter "" (without quotes)
> >3. Save the file.
> >4. Upload the file to your host.
> >5. Open a browser and enter the url (i.e., http://yourdomain.com/index.php)
> >
> >What do you see?
> >
> >Cheers,
> >
> >tedd
> 
> 
> Col:
> 
> You don't have to tell what you see, but rather do you see anything?
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com/
> 
Tedd:

He is working off his localhost, running on vista... so what it seems
(to me at least) is that he is getting the php to work when he uses the
localhost, but when he tries to open a php file from say his desktop, he
doesn't see the php stuff... which is exactly as designed since running
form your desktop, php does not execute the code... 

i am guessing that he just needs to use his localhost directory.

Steve.


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



[PHP] which one is faster

2010-10-05 Thread saeed ahmed
$a = 'hey';
$b = 'done';

$c = $a.$b;
$c = "$a$b";

which one is faster for echo $c.


Re: [PHP] which one is faster

2010-10-05 Thread chris h
Benchmark and find out! :)

What are you using this for? Unless you are doing something crazy it
probably doesn't matter, and you should pick whichever you feel looks nicer
/ is easier to code in / etc.

Chris H.

On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed  wrote:

> $a = 'hey';
> $b = 'done';
>
> $c = $a.$b;
> $c = "$a$b";
>
> which one is faster for echo $c.
>


Re: [PHP] which one is faster

2010-10-05 Thread Ashley Sheridan
On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:

> Benchmark and find out! :)
> 
> What are you using this for? Unless you are doing something crazy it
> probably doesn't matter, and you should pick whichever you feel looks nicer
> / is easier to code in / etc.
> 
> Chris H.
> 
> On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed  wrote:
> 
> > $a = 'hey';
> > $b = 'done';
> >
> > $c = $a.$b;
> > $c = "$a$b";
> >
> > which one is faster for echo $c.
> >


As far as I'm aware, the first of the two will be faster, but only just.
As Saeed mentioned, the difference will be negligible, and unless you
plan to run a line like that in a loop or something hundreds of
thousands of times, you probably won't notice any difference.
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] which one is faster

2010-10-05 Thread chris h
Saeed here's a quick (and dirty) test I ran:


$tests = 100;

$start = microtime(true);
for ($i=0; $i<$tests; $i++) {

  $a = md5( rand() );
  $b = md5( rand() );

  $c = $a.$b;
}
var_dump( "By concat op:\t". (microtime(true) - $start) );


$start = microtime(true);
for ($i=0; $i<$tests; $i++) {

  $a = md5( rand() );
  $b = md5( rand() );

  $c = "$a$b";
}
var_dump( "By string:\t\t". (microtime(true) - $start) );


Sample results:
string(30) "By concat op: 2.1713118553162"
string(27) "By string: 2.2525599002838"

string(30) "By concat op: 2.2123351097107"
string(27) "By string: 2.2798750400543"

string(29) "By concat op: 2.1521489620209"
string(27) "By string: 2.2470209598541"

string(29) "By concat op: 2.1347990036011"
string(27) "By string: 2.1982681751251"


I would say that under virtually all cases that difference is less
then negligible.

Chris H.

On Tue, Oct 5, 2010 at 3:35 PM, Ashley Sheridan 
wrote:

>  On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
>
> Benchmark and find out! :)
>
> What are you using this for? Unless you are doing something crazy it
> probably doesn't matter, and you should pick whichever you feel looks nicer
> / is easier to code in / etc.
>
> Chris H.
>
> On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed  wrote:
>
> > $a = 'hey';
> > $b = 'done';
> >
> > $c = $a.$b;
> > $c = "$a$b";
> >
> > which one is faster for echo $c.
> >
>
>
> As far as I'm aware, the first of the two will be faster, but only just. As
> Saeed mentioned, the difference will be negligible, and unless you plan to
> run a line like that in a loop or something hundreds of thousands of times,
> you probably won't notice any difference.
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


Re: [PHP] which one is faster

2010-10-05 Thread Steve Staples
On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
> On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
> 
> > Benchmark and find out! :)
> > 
> > What are you using this for? Unless you are doing something crazy it
> > probably doesn't matter, and you should pick whichever you feel looks nicer
> > / is easier to code in / etc.
> > 
> > Chris H.
> > 
> > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed  wrote:
> > 
> > > $a = 'hey';
> > > $b = 'done';
> > >
> > > $c = $a.$b;
> > > $c = "$a$b";
> > >
> > > which one is faster for echo $c.
> > >
> 
> 
> As far as I'm aware, the first of the two will be faster, but only just.
> As Saeed mentioned, the difference will be negligible, and unless you
> plan to run a line like that in a loop or something hundreds of
> thousands of times, you probably won't notice any difference.
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 


to be proper, shouldn't it technically be
$c = "{$a}{$b}";

??

Steve.


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



[PHP] Variable (Class instantiation) collision

2010-10-05 Thread Brian Smither
I am running into a variable collision. The project I'm developing is NOT 
guaranteed to be operating on PHP5. Any solution I find should (hopefully) be 
able to run on PHP4 (yes, I know PHP4 is deprecated).

I am building a bridge between two third-party applications. Both instantiate 
their respective database class assigning it to $db and I cannot change that.

So, I am interested in solutions to this.

I found a reference to a Packager class and will be looking at it shortly.



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



Re: [PHP] which one is faster

2010-10-05 Thread Ashley Sheridan
On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:

> On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
> > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
> > 
> > > Benchmark and find out! :)
> > > 
> > > What are you using this for? Unless you are doing something crazy it
> > > probably doesn't matter, and you should pick whichever you feel looks 
> > > nicer
> > > / is easier to code in / etc.
> > > 
> > > Chris H.
> > > 
> > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed  wrote:
> > > 
> > > > $a = 'hey';
> > > > $b = 'done';
> > > >
> > > > $c = $a.$b;
> > > > $c = "$a$b";
> > > >
> > > > which one is faster for echo $c.
> > > >
> > 
> > 
> > As far as I'm aware, the first of the two will be faster, but only just.
> > As Saeed mentioned, the difference will be negligible, and unless you
> > plan to run a line like that in a loop or something hundreds of
> > thousands of times, you probably won't notice any difference.
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> 
> 
> to be proper, shouldn't it technically be
> $c = "{$a}{$b}";
> 
> ??
> 
> Steve.
> 
> 


It doesn't have to use the braces. The braces only tell PHP exactly
where to stop parsing the current variable name. The following examples
wouldn't work without them:

$var = 'hello ';
$arr = array('msg 1'=>'hello','msg 2'=>'world');

echo "{$var}world";
echo "{$arr['msg 1']}{$arr['msg 2']}";

Without the braces, in the first example PHP would look for a variable
called $varworld, and in the second it would be looking for a simple
scaler called $arr, not the array value you wanted.

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




Re: [PHP] which one is faster

2010-10-05 Thread chris h
On Tue, Oct 5, 2010 at 3:53 PM, Ashley Sheridan 
wrote:

> On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
>
> > On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
> > > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
> > >
> > > > Benchmark and find out! :)
> > > >
> > > > What are you using this for? Unless you are doing something crazy it
> > > > probably doesn't matter, and you should pick whichever you feel looks
> nicer
> > > > / is easier to code in / etc.
> > > >
> > > > Chris H.
> > > >
> > > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed 
> wrote:
> > > >
> > > > > $a = 'hey';
> > > > > $b = 'done';
> > > > >
> > > > > $c = $a.$b;
> > > > > $c = "$a$b";
> > > > >
> > > > > which one is faster for echo $c.
> > > > >
> > >
> > >
> > > As far as I'm aware, the first of the two will be faster, but only
> just.
> > > As Saeed mentioned, the difference will be negligible, and unless you
> > > plan to run a line like that in a loop or something hundreds of
> > > thousands of times, you probably won't notice any difference.
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > >
> >
> >
> > to be proper, shouldn't it technically be
> > $c = "{$a}{$b}";
> >
> > ??
> >
> > Steve.
> >
> >
>
>
> It doesn't have to use the braces. The braces only tell PHP exactly
> where to stop parsing the current variable name. The following examples
> wouldn't work without them:
>
> $var = 'hello ';
> $arr = array('msg 1'=>'hello','msg 2'=>'world');
>
> echo "{$var}world";
> echo "{$arr['msg 1']}{$arr['msg 2']}";
>
> Without the braces, in the first example PHP would look for a variable
> called $varworld, and in the second it would be looking for a simple
> scaler called $arr, not the array value you wanted.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
Just to add in here, they are also required when calling an object's
properties, if - ready for this? - that object is itself a property of
another object.

so while this would work,

"$circle->circumference"

this would NOT work

"$circle->circumference->inches"

The later would be injecting the $circle->circumference property, followed
by string literal "->inches".  So to get it to work you would need to use
curlys.

"{$circle->circumference->inches}"


Chris H.


Re: [PHP] which one is faster

2010-10-05 Thread TR Shaw

On Oct 5, 2010, at 3:23 PM, saeed ahmed wrote:

> $a = 'hey';
> $b = 'done';
> 
> $c = $a.$b;
> $c = "$a$b";
> 
> which one is faster for echo $c.

Depends upon the platform its running on.



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



Re: [PHP] which one is faster

2010-10-05 Thread Steve Staples
On Tue, 2010-10-05 at 20:53 +0100, Ashley Sheridan wrote:
> On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
> 
> > On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
> > > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
> > > 
> > > > Benchmark and find out! :)
> > > > 
> > > > What are you using this for? Unless you are doing something crazy it
> > > > probably doesn't matter, and you should pick whichever you feel looks 
> > > > nicer
> > > > / is easier to code in / etc.
> > > > 
> > > > Chris H.
> > > > 
> > > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed  wrote:
> > > > 
> > > > > $a = 'hey';
> > > > > $b = 'done';
> > > > >
> > > > > $c = $a.$b;
> > > > > $c = "$a$b";
> > > > >
> > > > > which one is faster for echo $c.
> > > > >
> > > 
> > > 
> > > As far as I'm aware, the first of the two will be faster, but only just.
> > > As Saeed mentioned, the difference will be negligible, and unless you
> > > plan to run a line like that in a loop or something hundreds of
> > > thousands of times, you probably won't notice any difference.
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > > 
> > > 
> > 
> > 
> > to be proper, shouldn't it technically be
> > $c = "{$a}{$b}";
> > 
> > ??
> > 
> > Steve.
> > 
> > 
> 
> 
> It doesn't have to use the braces. The braces only tell PHP exactly
> where to stop parsing the current variable name. The following examples
> wouldn't work without them:
> 
> $var = 'hello ';
> $arr = array('msg 1'=>'hello','msg 2'=>'world');
> 
> echo "{$var}world";
> echo "{$arr['msg 1']}{$arr['msg 2']}";
> 
> Without the braces, in the first example PHP would look for a variable
> called $varworld, and in the second it would be looking for a simple
> scaler called $arr, not the array value you wanted.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 
Ash:

I understand what the {} does, but just like in HTML, it is more proper
to use lower case for the attributes/elements, and use " (double quotes)
when wrapping the attributes... but is it not "REQUIRED" to write it in
that manner... just like it is not required to wrap the variables in {}
when inside the ""... 

that's just me, I tend to try and do that every time... 

Steve.


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



Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Just to clarify, both packages are instantiating and calling their
respective database classes from the $db var, which is in the global scope.
Is this correct?

This is why I hate the global scope, I hate it, I hate it!

On Tue, Oct 5, 2010 at 3:47 PM, Brian Smither  wrote:

> I am running into a variable collision. The project I'm developing is NOT
> guaranteed to be operating on PHP5. Any solution I find should (hopefully)
> be able to run on PHP4 (yes, I know PHP4 is deprecated).
>
> I am building a bridge between two third-party applications. Both
> instantiate their respective database class assigning it to $db and I cannot
> change that.
>
> So, I am interested in solutions to this.
>
> I found a reference to a Packager class and will be looking at it shortly.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] which one is faster

2010-10-05 Thread Ashley Sheridan
On Tue, 2010-10-05 at 15:58 -0400, Steve Staples wrote:

> On Tue, 2010-10-05 at 20:53 +0100, Ashley Sheridan wrote:
> > On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
> > 
> > > On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
> > > > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
> > > > 
> > > > > Benchmark and find out! :)
> > > > > 
> > > > > What are you using this for? Unless you are doing something crazy it
> > > > > probably doesn't matter, and you should pick whichever you feel looks 
> > > > > nicer
> > > > > / is easier to code in / etc.
> > > > > 
> > > > > Chris H.
> > > > > 
> > > > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed  
> > > > > wrote:
> > > > > 
> > > > > > $a = 'hey';
> > > > > > $b = 'done';
> > > > > >
> > > > > > $c = $a.$b;
> > > > > > $c = "$a$b";
> > > > > >
> > > > > > which one is faster for echo $c.
> > > > > >
> > > > 
> > > > 
> > > > As far as I'm aware, the first of the two will be faster, but only just.
> > > > As Saeed mentioned, the difference will be negligible, and unless you
> > > > plan to run a line like that in a loop or something hundreds of
> > > > thousands of times, you probably won't notice any difference.
> > > > Thanks,
> > > > Ash
> > > > http://www.ashleysheridan.co.uk
> > > > 
> > > > 
> > > 
> > > 
> > > to be proper, shouldn't it technically be
> > > $c = "{$a}{$b}";
> > > 
> > > ??
> > > 
> > > Steve.
> > > 
> > > 
> > 
> > 
> > It doesn't have to use the braces. The braces only tell PHP exactly
> > where to stop parsing the current variable name. The following examples
> > wouldn't work without them:
> > 
> > $var = 'hello ';
> > $arr = array('msg 1'=>'hello','msg 2'=>'world');
> > 
> > echo "{$var}world";
> > echo "{$arr['msg 1']}{$arr['msg 2']}";
> > 
> > Without the braces, in the first example PHP would look for a variable
> > called $varworld, and in the second it would be looking for a simple
> > scaler called $arr, not the array value you wanted.
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> Ash:
> 
> I understand what the {} does, but just like in HTML, it is more proper
> to use lower case for the attributes/elements, and use " (double quotes)
> when wrapping the attributes... but is it not "REQUIRED" to write it in
> that manner... just like it is not required to wrap the variables in {}
> when inside the ""... 
> 
> that's just me, I tend to try and do that every time... 
> 
> Steve.
> 
> 


Not really, it's no more proper than the difference between:

echo 'text' . $var;
 or
echo "text$var";

And in some cases, it is required. It is down to preference if you use
them when you don't have to, but personally I'd avoid typing what is
essentially useless fluff.


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




Re: [PHP] which one is faster

2010-10-05 Thread chris h
On Tue, Oct 5, 2010 at 3:58 PM, Steve Staples  wrote:

> On Tue, 2010-10-05 at 20:53 +0100, Ashley Sheridan wrote:
> > On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
> >
> > > On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
> > > > On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
> > > >
> > > > > Benchmark and find out! :)
> > > > >
> > > > > What are you using this for? Unless you are doing something crazy
> it
> > > > > probably doesn't matter, and you should pick whichever you feel
> looks nicer
> > > > > / is easier to code in / etc.
> > > > >
> > > > > Chris H.
> > > > >
> > > > > On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed 
> wrote:
> > > > >
> > > > > > $a = 'hey';
> > > > > > $b = 'done';
> > > > > >
> > > > > > $c = $a.$b;
> > > > > > $c = "$a$b";
> > > > > >
> > > > > > which one is faster for echo $c.
> > > > > >
> > > >
> > > >
> > > > As far as I'm aware, the first of the two will be faster, but only
> just.
> > > > As Saeed mentioned, the difference will be negligible, and unless you
> > > > plan to run a line like that in a loop or something hundreds of
> > > > thousands of times, you probably won't notice any difference.
> > > > Thanks,
> > > > Ash
> > > > http://www.ashleysheridan.co.uk
> > > >
> > > >
> > >
> > >
> > > to be proper, shouldn't it technically be
> > > $c = "{$a}{$b}";
> > >
> > > ??
> > >
> > > Steve.
> > >
> > >
> >
> >
> > It doesn't have to use the braces. The braces only tell PHP exactly
> > where to stop parsing the current variable name. The following examples
> > wouldn't work without them:
> >
> > $var = 'hello ';
> > $arr = array('msg 1'=>'hello','msg 2'=>'world');
> >
> > echo "{$var}world";
> > echo "{$arr['msg 1']}{$arr['msg 2']}";
> >
> > Without the braces, in the first example PHP would look for a variable
> > called $varworld, and in the second it would be looking for a simple
> > scaler called $arr, not the array value you wanted.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> Ash:
>
> I understand what the {} does, but just like in HTML, it is more proper
> to use lower case for the attributes/elements, and use " (double quotes)
> when wrapping the attributes... but is it not "REQUIRED" to write it in
> that manner... just like it is not required to wrap the variables in {}
> when inside the ""...
>
> that's just me, I tend to try and do that every time...
>
> Steve.
>
>

Unlike HTML, PHP interpretation doesn't have various browsers to contend
with. And even if it was not proper I have a doubt that not using {} would
become deprecated anytime soon.

Also laziness is a trait of a good programmer! :)
http://c2.com/cgi/wiki?LazinessImpatienceHubris

Chris H.


[PHP] Re: which one is faster

2010-10-05 Thread Jo�o C�ndido de Souza Neto
As I can see, it´d be too much faster to decide by yourself than reading all 
theese answers and understanding their differences and taking people´s time 
for nothing.

-- 
João Cândido de Souza Neto

"saeed ahmed"  escreveu na mensagem 
news:aanlktikh6g5ilsz3hkxatg=h1wzobgoko7byngo0p...@mail.gmail.com...
> $a = 'hey';
> $b = 'done';
>
> $c = $a.$b;
> $c = "$a$b";
>
> which one is faster for echo $c.
> 



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



Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread Brian Smither

>Just to clarify, both packages are instantiating and calling their
>respective classes from the $db var, which is in the global scope.
>Is this correct?

I would say yes to the way you are asking. Take the following two applications. 
The four respective statements are in each their respective script.

Application A:


Application B:


The bridge project is operating in A and include()'ing the script that is B (as 
I have not found an API for B). $db in B is colliding with $db in A.



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



Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Short of refactoring ApplicationB, can you set it up as a SOAP/REST service
that AppA calls?


On Tue, Oct 5, 2010 at 5:02 PM, Brian Smither  wrote:

>
> >Just to clarify, both packages are instantiating and calling their
> >respective classes from the $db var, which is in the global scope.
> >Is this correct?
>
> I would say yes to the way you are asking. Take the following two
> applications. The four respective statements are in each their respective
> script.
>
> Application A:
>  class foo {}
> $db = new foo();
> $outA = barA();
> function barA() { global $db; include("Application B"); }
> ?>
>
> Application B:
>  class bar {}
> $db = new bar();
> $outB = barB();
> function barB() { global $db; }
> ?>
>
> The bridge project is operating in A and include()'ing the script that is B
> (as I have not found an API for B). $db in B is colliding with $db in A.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread David Harkness
If you have total control over application A which contains the bridge code,
the easiest is to change it to use a different global variable, $dbA. This
must not be doable or you wouldn't have asked.

If you have control over the bridge code, and it alone calls A and B, then
you could swap the $db variables between calls:

$db = null;
$dbA = null;
$dbB = null;

function copyPersons() {
useA();
$persons = loadPersonsFromA();
useB();
savePersonsInB($persons);
}

function connect() {
global $db, $dbA, $dbB;
connectToA();
$dbA = $db;
unset($db);
connectToB();
$dbB = $db;
unset($db);
}

function useA() {
global $db, $dbA;
$db = $dbA;
}

function useB() {
global $db, $dbB;
$db = $dbB;
}

This is the simplest implementation. You could get trickier by tracking
which system is in use and only swapping them as-needed, writing a facade
around the APIs to A and B. It's ugly, but it works.

David