[PHP] Please help to unsubscribe

2011-08-27 Thread Eli Orr
The advised email to unsubscribe does not work: 
php-general-unsubscr...@lists.php.net

Thanks

Eli



-- 



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



Re: [PHP] Ftp upload

2011-06-14 Thread Eli Orr (Office)

Dear Experts,

Can you please advise how can I detect a string if it is UTF-8 or now 
and how can I if possible

convert a string to a utf-8 ?

Here's the string I got from client - client sends it via POST with 
urlencode and does apply UTF-8

encoding on the string.

Here's the string I got:   
However I do not get the string as a utf-8 (After I do urldecode to the 
client POST parameter)


Please advise

Eli


[PHP] PHP to Java integration using : shell_exec function

2011-05-26 Thread Eli Orr (Office)


Hi,

Please advise if the following is possible and how can pass parameters 
from the PHP to the Java application.


Thanks.

Here's my script draft:

?PHP
  ...
  
  $XML_toEnc = urlencode ($XML);

 // The XML_toEnc 
is a string and shall be urlencoded !
  $EncXML = shell_exec(/usr/bin/java/java -jar MyApp.jar -XML 
$XML_toEnc); == ??? How can I pass parameters like a large string of 
let say XML?


echo  $EncXML; // back to the MObile Client

// Receiving client shall:
//  urldecode the string


?


Eli Orr


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



[PHP] How can a UTF-8 string can be converted to an array of Bytes?

2011-05-25 Thread Eli Orr (Office)

Hi,

Since a UTF-8 is a multi-bytes mechanism I get for 2 or 3 bytes  UTF-8 
encoded character a single character


How can it be break into the REAL bytes array that represent the UTF-8 
string

 and how  can we reassembled the bytes array  back to UTF-8?

--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*

__


[PHP] GnuPG from PHP - Where is the include ??

2011-05-24 Thread Eli Orr (Office)
Please advise - I'guess it is not a build in and looking for the GnuPG 
PHP include as

all the GnuPG functions are now considered undefined.

See below.

Thanks

Eli

//  GnuPG from PHP - Where is the include ??
//  http://www.gnupg.org/gph/en/manual.html
//  http://www.gnupg.org/documentation/howtos.en.html
//  GnuPG allows to encrypt and sign your data and communication,
//  features a versatile key management system as well as access
//  modules for all kinds of public key directories.
//

echo GNU Encrypt with agreed secret key between sides.;

$secret_key = 8660281B6051D071D94B5B230549F9DC851566DC; // Only shared 
parties know this
$the_secret_content  = this is a very secret XML keep the secret key in 
the server and client well hidden from 4rd parties; // Only shared 
parties know this


echo Secret Key between Parties: [$secret_key] br;
echo The sensitive content to keep safe br
 from 3rd parties: b $the_secret_content /bbr;


//Creating the encryption content
$res = gnupg_init();
gnupg_addencryptkey($res, $secret_key);
$enc = gnupg_encrypt($res, $the_secret_content);
echo This is the sensitive content encrypted by strong shared secret 
key:[.$enc.] br;


echo Secret Key between Parties: [$secret_key] br;

 $res = gnupg_init();
gnupg_adddecryptkey($res,$secret_key);
$plain = gnupg_decrypt($res, $enc);

echo This is the sensitive content decrypted by recieving party br
 that has the shared secret key:[.$plain.] br;

_

_


Re: [PHP] Check the byte sequence of a file to tell if it is UTF-8 without the BOM using PHP ?

2011-05-22 Thread Eli Orr (Office)

Hi Adam,

I have a prof that the XML advise does not work in real cases I had.
We are using XMLs in our system but when you edit the XML with  a text 
editor and put the XML heading of UTF-8

?xml version=1.0 encoding=UTF-8?

it DOES NOT assure the text inside is encoded in UTF-8 so but maybe 
(many cases) t other iso-xxx method.


My question was for a function that scan the bytes of the file and 
decided WITHOUT the BOM heading.

I mean by checking the bytes sequence in the file.

I claim that WITHOUT a BOM it might be impossible to assure it is UTF-8 
encoding which is a whole escape sequence logic

that may convert one character into one, two or three character.

Any advise if I'm right on this or smart file scan function that makes it?

Eli
On 21/05/2011 20:03, Adam Richardson wrote:
On Sat, May 21, 2011 at 12:10 PM, Eli Orr (Office) 
eli@logodial.com mailto:eli@logodial.com wrote:



Dear PHP Gurus,

I have a debate on the following please let me know what is true /
false.

I'am using a PHP function *is_UTF_8_file ($file_name) *that I've
found as part of my PHP 5.3 installation.
This function checks if the file start with the 3 UTF-8 BOM bytes.

However another guy told me that there is way to detect if a file
is a UTF-8 without having the BOM at the file start.
To me it sounds impossible since if you do not have this
indication you have a stream of bytes that you can never tell 100%
if that is UTF-8 or else.

Who is rigt here ?
If there is a Magical function that can detect files without a BOM
if they are UTF-8 or not please share you knowledge if this
is not a NULL or impossible function as I thought.


Here's a great write-up I've got bookmarked (he points out Windows 
Notepad automatically determines the encoding):

http://codesnipers.com/?q=node/68

* If it's an XML file, the structure allows you determine the
  encoding.
* For other files, you can encode it as UTF-8 and look for
  improper encodings.


As far as a PHP function that already does this, I'm not aware of it, 
but you could make a system call to file if your on Linux, as it 
tries to automatically determine the encoding:

http://linux.die.net/man/1/file

Adam

--
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com



--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


Re: [PHP] Check the byte sequence of a file to tell if it is UTF-8 without the BOM using PHP ?

2011-05-22 Thread Eli Orr (Office)

Dear Peter,

But my point was different.

If you DO NOT have any BOM of a File does

mb_detect_encodin


can detect the file type by scanning the whole file ??

Thanks

Eli

On 22/05/2011 09:53, Peter Lind wrote:

On 22 May 2011 08:17, Eli Orr (Office)eli@logodial.com  wrote:

Hi Adam,

I have a prof that the XML advise does not work in real cases I had.
We are using XMLs in our system but when you edit the XML with  a text
editor and put the XML heading of UTF-8
?xml version=1.0 encoding=UTF-8?

it DOES NOT assure the text inside is encoded in UTF-8 so but maybe (many
cases) t other iso-xxx method.

The point of the header is telling readers what encoding is used. Of
course that means errors are possible - setting the header is not
magic, it doesn't change the rest of the file. You need to make sure
the contents of the file match the encoding from the header when you
make XML documents.

Anyway, from your perspective, the header is an indication but not a
foolproof way of figuring encoding out.


My question was for a function that scan the bytes of the file and decided
WITHOUT the BOM heading.
I mean by checking the bytes sequence in the file.

I claim that WITHOUT a BOM it might be impossible to assure it is UTF-8
encoding which is a whole escape sequence logic
that may convert one character into one, two or three character.

http://se.php.net/manual/en/function.mb-detect-encoding.php - the
first comment should be interesting to you.

*
If you try to use mb_detect_encoding to detect whether a string is
valid UTF-8, use the strict mode, it is pretty worthless otherwise.

?php
 $str = 'áéóú'; // ISO-8859-1
 mb_detect_encoding($str, 'UTF-8'); // 'UTF-8'
 mb_detect_encoding($str, 'UTF-8', true); // false
?


Regards
Peter




--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


Re: [PHP] Check the byte sequence of a file to tell if it is UTF-8 without the BOM using PHP ?

2011-05-22 Thread Eli Orr (Office)

Thank you Peter.

Can you please advise if

mb_detect_encodin does detect the file type by its structure / content?

Thanks

Eli

 


On 22/05/2011 10:12, Peter Lind wrote:

On 22 May 2011 09:03, Eli Orr (Office)eli@logodial.com  wrote:

Dear Peter,

But my point was different.

If you DO NOT have any BOM of a File does

mb_detect_encodin

can detect the file type by scanning the whole file ??


A few points:
1. top-posting on this list is frowned upon. Please bottom-post.
2. I did not write anything about BOM as far as I can recall. Neither
does the page I linked to contain much about BOM (I really suggest
reading it - as pointed out, the first comment should help you)

Regards
Peter




--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


[PHP] a Debate here - How can you check a if a file is a UTF-8 without the BOM using PHP ?

2011-05-21 Thread Eli Orr (Office)


Dear PHP Gurus,

I have a debate on the following please let me know what is true / false.

I'am using a PHP function *is_UTF_8_file ($file_name) *that I've found 
as part of my PHP 5.3 installation.

This function checks if the file start with the 3 UTF-8 BOM bytes.

However another guy told me that there is way to detect if a file is a 
UTF-8 without having the BOM at the file start.
To me it sounds impossible since if you do not have this indication you 
have a stream of bytes that you can never tell 100% if that is UTF-8 or 
else.


Who is rigt here ?
If there is a Magical function that can detect files without a BOM if 
they are UTF-8 or not please share you knowledge if this

is not a NULL or impossible function as I thought.

Many thanks for you wise advise.

--
Best Regards,

*Eli Orr*
*LogoDial Ltd.*
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


[PHP] Sending Email via SMTP account using PHP

2011-05-18 Thread Eli Orr (Office)


Hi,
I'm looking for a good example for using a real SMTP account to send 
email from,
such as serv...@somai.com where there is a user  password and smtp 
server available.


Please advise with a good example to reuse,

Thanks

Eli

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



Re: [PHP] Sending Email via SMTP account using PHP

2011-05-18 Thread Eli Orr (Office)

Thanks Daniel!

It works perfect.

Eli

On 18/05/2011 17:47, Daniel Brown wrote:

On Wed, May 18, 2011 at 03:17, Eli Orr (Office)eli@logodial.com  wrote:

Hi,
I'm looking for a good example for using a real SMTP account to send email
from,
such as serv...@somai.com where there is a user  password and smtp server
available.

Please advise with a good example to reuse,

 Try this:

 http://links.parasane.net/boqp






--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


[PHP] How to enable UTF-8 Subject String ? Only Body is set ok

2011-05-17 Thread Eli Orr (Office)

Hi,

I'm trying to enable a whole Email as UTF-8 - The Body is OK but the 
Subject remains ANSI - Please help


  $headers = From:$from. \r\n .
   Reply-To:$from . \r\n .
   *Content-type:text/html;charset=utf-8;*.\r\n .
   X-Mailer: PHP/.phpversion();



--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


[PHP] How to DUMP $_POST parameters to a log file? Very useful and missing in the php.net

2011-05-08 Thread Eli Orr (Office)


Dear PHP Gurus,

I need dump a $_POST parameters as part of debug process with a client.
Any know service to make this ?

I know $_POST is an Array but I look for a service function  that can 
save the parsed array into a file.

let say :

$stt = save_POST_into_file ($_POST, $fp);


Any idea ?


--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


Re: [PHP] How to DUMP $_POST parameters to a log file? Very useful and missing in the php.net

2011-05-08 Thread Eli Orr (Office)

Thanks. Great! It works so well !

On 08/05/2011 15:01, Peter Lind wrote:

On May 8, 2011 1:57 PM, Eli Orr (Office)eli@logodial.com  wrote:


Dear PHP Gurus,

I need dump a $_POST parameters as part of debug process with a client.
Any know service to make this ?

I know $_POST is an Array but I look for a service function  that can save

the parsed array into a file.

let say :

$stt = save_POST_into_file ($_POST, $fp);


file_put_contents($filename, print_r($array, true));

Regards




--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


[PHP] Improve server HTTP GET server response - HTTP 1.1 ?

2011-04-26 Thread Eli Orr (Office)

Dear PHP Gurus,

I have wrote a service that respond to a client HTTP GET request with 
BLOB of data:

http://mimmage.com/cms/client_initialize1.php?OPERATOR=MIRSID=23412341234OS=RIM

The first time I call the HTTP GET it works very slow.. next calls it 
works much faster.

Please advise how can I enhance the server response in the first call.
Any method for the client to initialize a standby like service with the 
server ahead of the specific request ?


Is there any way HTTP 1.1 operation fashion can speed it up ?
e.g.  http://www8.org/w8-papers/5c-protocols/key/key.html

Looking forward for your wise and experienced advise for this heavy issue.

Thanks

Eli
eliorr.com


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



Re: [PHP] Improve server HTTP GET server response - HTTP 1.1 ?

2011-04-26 Thread Eli Orr (Office)


Dear Ash,

I could not follow on how it can be faster using your advise.
Seems you focus on how it could be slower using a random suffix each 
call to assure no caching is involved.


Any practical advise or references/example how to make it faster for the 
initial call ?

Any methods from the enhanced HTTP of V1.1 ?

Thanks

Eli


On 26/04/2011 21:00, Ashley Sheridan wrote:

On Tue, 2011-04-26 at 12:37 +0300, Eli Orr (Office) wrote:

Dear PHP Gurus,

I have wrote a service that respond to a client HTTP GET request with
BLOB of data:
http://mimmage.com/cms/client_initialize1.php?OPERATOR=MIRSID=23412341234OS=RIM  
http://mimmage.com/cms/client_initialize1.php?OPERATOR=MIRSID=23412341234OS=RIM

The first time I call the HTTP GET it works very slow.. next calls it
works much faster.
Please advise how can I enhance the server response in the first call.
Any method for the client to initialize a standby like service with the
server ahead of the specific request ?

Is there any way HTTP 1.1 operation fashion can speed it up ?
e.g.http://www8.org/w8-papers/5c-protocols/key/key.html

Looking forward for your wise and experienced advise for this heavy issue.

Thanks

Eli
eliorr.com




Could it be that there is some mechanism which is caching the response 
(which is fine for GET requests as they are intended to be cached) on 
the server?


Caching can be done in PHP (a lot of frameworks contain rudimentary 
caching functionality) or by Apache itself, so there are a few places 
you can check. To test for caching, have the client-side part of the 
request add a random suffix like ?t=timestamp so that the server 
thinks this request is unique. If each request comes back slow, it's 
likely that the subsequent ones being faster is the result of caching.


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





--
Best Regards,

*Eli Orr*
CTO  Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel
Email: _Eli.Orr@LogoDial.com_
Skype: _eliorr.com_


RE: [PHP] $_POST vars

2011-04-13 Thread Eli Orr
Hi Jim, 

Sure you can create set of et of $_POST vars :

e.g. 
form action=myphpaction.php method=POST

input type=password  name=admin_code value='Enter here..'
   onclick=if(this.value=='Enter here..'){this.value='';
this.style.color='#000'}
 onblur=if(this.value==''){this.value='Enter here..';
this.style.color='#555'} /
input type=submit VALUE=Execute / 
/form

So that  admin_code var is passed to myphpaction.php as post and shall be
access there via  $_POST[admin_code ]; 
However, note that in PHP all the output buffer is flushed actually,
ONLY after the script execution is  terminated. 

Skype:  eliorr.com


-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Sent: Wednesday, April 13, 2011 8:50 PM
To: php-general@lists.php.net
Subject: [PHP] $_POST vars

Can one create a set of $_POST vars within a script or is that not do-able? 
My display portion of my script utilizes the POST array to supply values to
my input screen - this works well for the first display of an empty screen,
and any following re-displays if there's an error in the user's input.  But
I want to use this same script/screen to display the results of a query when
the user wants to update an existing record. 



--
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] Eliminatimg PHP UTF-8 BOM in a returned stream to a Mobile App

2011-04-12 Thread Eli Orr
Dear PHP Gurus, 

I would like to Eliminate the 3 UTF-8 BOM enforced on my returned BLOB:

The PHP server adds  utf-8 BOM (UTF-8 Byte Order Mark  - in the beginning of
UTF-8  files) which 
consists of three bytes: EF BB BF.   

The Mobile App served by the server Does not need that. How can I eliminate
it??

Thanks.

UTF-8 Byte Order Mark – BOM:
http://unicode.org/faq/utf_bom.html#BOM

Best Regards, 

Eli  Orr
CTO  Founder 
Mimmage.com 
My virtual vCard 
LogoDial Ltd.
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604

Plaut 10, Rehovot, Israel 
Email:   eli@logodial.com
Skype:  eliorr.com


- 



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



RE: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to a Mobile App

2011-04-12 Thread Eli Orr

Hi Richard, 

Thanks.
Indeed, that is the case - I've included a code that has UTF-8 string contants 
-so I guess the PHP 
parser set the UTF-8 mode to ON so that the returned string to the client has 
the UTF-8 BOM. 

It is not a big issue as the mobile app guys aware of this and make the proper 
3 bytes offset.
Anyhow I was looking for a service to control that behaviour. 

 Thanks

Eli

-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Tuesday, April 12, 2011 12:45 PM
To: Eli Orr
Cc: php-general@lists.php.net
Subject: Re: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to a Mobile 
App

2011/4/12 Eli Orr eli@logodial.com:
 Dear PHP Gurus,

 I would like to Eliminate the 3 UTF-8 BOM enforced on my returned BLOB:

 The PHP server adds  utf-8 BOM (UTF-8 Byte Order Mark  - in the 
 beginning of
 UTF-8  files) which
 consists of three bytes: EF BB BF.

 The Mobile App served by the server Does not need that. How can I 
 eliminate it??

 Thanks.

 UTF-8 Byte Order Mark – BOM:
 http://unicode.org/faq/utf_bom.html#BOM

 Best Regards,

 Eli  Orr
 CTO  Founder
 Mimmage.com
 My virtual vCard
 LogoDial Ltd.
 M:+972-54-7379604
 O:+972-74-703-2034
 F: +972-77-3379604

 Plaut 10, Rehovot, Israel
 Email:   eli@logodial.com
 Skype:  eliorr.com


 -



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



Can you show us the PHP script that DOES output the BOM?

Normally, PHP doesn't do this automatically (AFAIK). The main reason being is 
that it is often the case that the BOM appears in the source code file before 
the ?php opening tag, so would block headers (session cookie for example).

If a BOM is being issued by PHP, it is being done programmatically, or is being 
missed due to the initial source code file having the BOM set.

See http://docs.php.net/manual/en/function.session-start.php#102431,
http://docs.php.net/manual/en/function.header.php#95864, etc.

Now. Having said all of that, you may find you are using some sort of output 
buffering and that is setting the BOM after the headers are sent.

But, as it stands, PHP will not be generating the BOM for 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



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



RE: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to a Mobile App

2011-04-12 Thread Eli Orr


Thanks Richard, 

Do you know a technique to mirror all the echo strings into a file for 
debugging ?

Eli

-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Tuesday, April 12, 2011 2:51 PM
To: Eli Orr
Cc: php-general@lists.php.net
Subject: Re: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to a Mobile 
App

On 12 April 2011 11:59, Eli Orr eli@logodial.com wrote:

 Hi Richard,

 Thanks.
 Indeed, that is the case - I've included a code that has UTF-8 string 
 contants -so I guess the PHP parser set the UTF-8 mode to ON so that the 
 returned string to the client has the UTF-8 BOM.

 It is not a big issue as the mobile app guys aware of this and make the 
 proper 3 bytes offset.
 Anyhow I was looking for a service to control that behaviour.

  Thanks

 Eli

 -Original Message-
 From: Richard Quadling [mailto:rquadl...@gmail.com]
 Sent: Tuesday, April 12, 2011 12:45 PM
 To: Eli Orr
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to a 
 Mobile App

 2011/4/12 Eli Orr eli@logodial.com:
 Dear PHP Gurus,

 I would like to Eliminate the 3 UTF-8 BOM enforced on my returned BLOB:

 The PHP server adds  utf-8 BOM (UTF-8 Byte Order Mark  - in the 
 beginning of
 UTF-8  files) which
 consists of three bytes: EF BB BF.

 The Mobile App served by the server Does not need that. How can I 
 eliminate it??

 Thanks.

 UTF-8 Byte Order Mark – BOM:
 http://unicode.org/faq/utf_bom.html#BOM

 Best Regards,

 Eli  Orr
 CTO  Founder
 Mimmage.com
 My virtual vCard
 LogoDial Ltd.
 M:+972-54-7379604
 O:+972-74-703-2034
 F: +972-77-3379604

 Plaut 10, Rehovot, Israel
 Email:   eli@logodial.com
 Skype:  eliorr.com


 -



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



 Can you show us the PHP script that DOES output the BOM?

 Normally, PHP doesn't do this automatically (AFAIK). The main reason being is 
 that it is often the case that the BOM appears in the source code file before 
 the ?php opening tag, so would block headers (session cookie for example).

 If a BOM is being issued by PHP, it is being done programmatically, or is 
 being missed due to the initial source code file having the BOM set.

 See http://docs.php.net/manual/en/function.session-start.php#102431,
 http://docs.php.net/manual/en/function.header.php#95864, etc.

 Now. Having said all of that, you may find you are using some sort of output 
 buffering and that is setting the BOM after the headers are sent.

 But, as it stands, PHP will not be generating the BOM for 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




No. The parser does not _ADD_ the BOM.

The bom already exists in your source code. Nothing to do with PHP.

The file you included that has the UTF-8 constants has the BOM.

You need to edit that file and remove the BOM. The actions you need to take 
will depend upon your editor.

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



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



RE: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to a Mobile App

2011-04-12 Thread Eli Orr
Hi Richard, 

Thanks. 
I've already got a solution to simply use Notes++ and save the PHP script 
with Save As encoding set to ANSI (It was UTF-8 indeed that creates the BOM...).

Thanks again

Eli

-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Tuesday, April 12, 2011 2:59 PM
To: Eli Orr
Cc: php-general@lists.php.net
Subject: Re: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to a Mobile 
App

On 12 April 2011 12:50, Richard Quadling rquadl...@gmail.com wrote:
 On 12 April 2011 11:59, Eli Orr eli@logodial.com wrote:

 Hi Richard,

 Thanks.
 Indeed, that is the case - I've included a code that has UTF-8 string 
 contants -so I guess the PHP parser set the UTF-8 mode to ON so that the 
 returned string to the client has the UTF-8 BOM.

 It is not a big issue as the mobile app guys aware of this and make the 
 proper 3 bytes offset.
 Anyhow I was looking for a service to control that behaviour.

  Thanks

 Eli

 -Original Message-
 From: Richard Quadling [mailto:rquadl...@gmail.com]
 Sent: Tuesday, April 12, 2011 12:45 PM
 To: Eli Orr
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Eliminatimg PHP UTF-8 BOM in a returned stream to 
 a Mobile App

 2011/4/12 Eli Orr eli@logodial.com:
 Dear PHP Gurus,

 I would like to Eliminate the 3 UTF-8 BOM enforced on my returned BLOB:

 The PHP server adds  utf-8 BOM (UTF-8 Byte Order Mark  - in the 
 beginning of
 UTF-8  files) which
 consists of three bytes: EF BB BF.

 The Mobile App served by the server Does not need that. How can I 
 eliminate it??

 Thanks.

 UTF-8 Byte Order Mark – BOM:
 http://unicode.org/faq/utf_bom.html#BOM

 Best Regards,

 Eli  Orr
 CTO  Founder
 Mimmage.com
 My virtual vCard
 LogoDial Ltd.
 M:+972-54-7379604
 O:+972-74-703-2034
 F: +972-77-3379604

 Plaut 10, Rehovot, Israel
 Email:   eli@logodial.com
 Skype:  eliorr.com


 -



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



 Can you show us the PHP script that DOES output the BOM?

 Normally, PHP doesn't do this automatically (AFAIK). The main reason being 
 is that it is often the case that the BOM appears in the source code file 
 before the ?php opening tag, so would block headers (session cookie for 
 example).

 If a BOM is being issued by PHP, it is being done programmatically, or is 
 being missed due to the initial source code file having the BOM set.

 See http://docs.php.net/manual/en/function.session-start.php#102431,
 http://docs.php.net/manual/en/function.header.php#95864, etc.

 Now. Having said all of that, you may find you are using some sort of output 
 buffering and that is setting the BOM after the headers are sent.

 But, as it stands, PHP will not be generating the BOM for 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




 No. The parser does not _ADD_ the BOM.

 The bom already exists in your source code. Nothing to do with PHP.

 The file you included that has the UTF-8 constants has the BOM.

 You need to edit that file and remove the BOM. The actions you need to 
 take will depend upon your editor.

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


To be a bit more specific...

The BOM is the 3 bytes you correctly identified earlier.

Most editors won't show these when you edit the files.

But, for the sake of argument, let's just pretend they are visible and look 
like ...

#@

In the php script that contains some UTF-8 constants, the file would look like 
...

#@php
echo '₩'; // The Fullwidth Won sign.
?

As PHP will only actually parse the content between ?php and ?, the #@ 
string (the BOM) is simply sent straight through to the web server
- the client with no interruption.

Now, if your code was ...

#@php
session_start();
?

you would see the headers already sent error message, as the BOM tells the 
webserver that data is now being received and to send any headers it already 
has.

So when the session_start() wants to send the session cookie (which is done as 
a HTTP Header), PHP already knows some content has gone (the
BOM) and reports the error.

To iterate, PHP is NOT generating the BOM. You already did that in your code. 
Well, the editor did it for you.

Ideally, you want to turn off the BOM in your editor.

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



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



[PHP] PHP DOM saveHTML outputs entities

2007-03-21 Thread Eli

Hi,

I'm loading a utf-8 xml file into PHP5 DOM, and then use saveHTML() 
method. The result output always convert characters to html entities in 
any case.
How can I avoid this? I want to output utf-8 html string with no html 
entities.


-thanks!

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



[PHP] Re: PHP DOM saveHTML outputs entities

2007-03-21 Thread Eli

What about html_entity_decode?
http://www.php.net/html_entity_decode 


No. It doesn't help in this case.

DOMDocument-saveHTML() method converts any non-ascii characters into 
entities.

For example, if the dom document has the text node value of:
שלום
It converts the string to entities:
#1513;#1500;#1493;#1501;
Although the string is already in UTF-8. The DOMDocument is already 
initialized with version 1.0 and encoding UTF-8, the php file is in 
UTF-8, the xml file is in UTF-8 and got ?xml version=1.0 
encoding=UTF-8? header.


Example:
?php
$dom = new DOMDocument('1.0','utf-8');
$dom-loadXML(htmlbodyשלום/body/html);
$output = $dom-saveHTML();
header(Content-Type: text/html; charset=UTF-8);
echo $output;
?

-thanks

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



Re: [PHP] Re: PHP DOM saveHTML outputs entities

2007-03-21 Thread Eli

Tijnema ! wrote:

Did you set the UTF8 format in the html_entity_decode function?
so your code would become:
?php
$dom = new DOMDocument('1.0','utf-8');
$dom-loadXML(htmlbodyשלום/body/html);
$output = $dom-saveHTML();
header(Content-Type: text/html; charset=UTF-8);
echo html_entity_decode($output,ENT_QUOTES,UTF-8);
?


Yes. This works... thanks! :-)

But actually I wanted to avoid the saveHTML() method from converting to 
html entities in the first place, if possible at all.


-thanks!

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



Re: [PHP] PHP DOM saveHTML outputs entities

2007-03-21 Thread Eli
Hi Nicholas,

Nicholas Yim wrote:
 how save() method

The save() method, or actually saveXML() method dumps the DOM in XML
format and not HTML format, and browsers do not know how to handle it
correctly.

-thanks

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



[PHP] Installing Apache + PHP on Windows

2007-02-22 Thread Eli

Hi,

I installed apache v2.2.4 and PHP v5.2.1 on Windows XP.
I try to use URLs like /info.php/virtual/path but I get error 404 all 
the time. I've also tried to set AcceptPathInfo for the vhosts directory.


Directory /my_vhosts_dir
Options Indexes FollowSymLinks
AcceptPathInfo On
Order Deny,Allow
Allow from all
/Directory

but this keeps failing.
What's wrong? How can I fix it?

-thanks!

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



[PHP] Re: Installing Apache + PHP on Windows

2007-02-22 Thread Eli

Eli wrote:

Hi,

I installed apache v2.2.4 and PHP v5.2.1 on Windows XP.
I try to use URLs like /info.php/virtual/path but I get error 404 all 
the time. I've also tried to set AcceptPathInfo for the vhosts directory.


Directory /my_vhosts_dir
Options Indexes FollowSymLinks
AcceptPathInfo On
Order Deny,Allow
Allow from all
/Directory

but this keeps failing.
What's wrong? How can I fix it?


Forgot to mention..
Installing in CGI mode... PHP scripts work fine but without PATH_INFO..
e.g:
/article.php?p=abc   --- works
/article.php/abc --- doesn't work

-thanks

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



[PHP] DOM Element default ID attribute

2007-02-21 Thread Eli

Hi,

I want to declare a default ID attribute to all elements in the document.
For example: If an element got the attribute 'id' then I want it 
automatically to become the ID attribute of the element.

How can I do that?

-thanks!

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



Re: [PHP] DOM Element default ID attribute

2007-02-21 Thread Eli

Peter Lauri wrote:

This was not clear for me, do you mean:

a peter = a id=peter



No.

Let me try to be more clear..
Say you got the element elem key=peter , then I want the DOMDocument 
to automatically convert the 'key' attribute to an ID-Attribute, as done 
with DOMElement::setIdAttribute() function. The ID-Attribute is indexed 
and can be quickly gotten via DOMDocument::getElementById() function.


I'm trying to avoid looping on all nodes overriding the importNode() and 
__construct() methods of DOMDocument.


-thanks.

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



Re: [PHP] array_pop() with key-value pair ???

2007-02-16 Thread Eli

Robin Vickery wrote:

On 16/02/07, Eli [EMAIL PROTECTED] wrote:

Hi,

Why isn't there a function that acts like array_pop() returns a pair of
key-value rather than the value only ?

Reason is, that in order to pop the key-value pair, you do:
?php
$arr = array('a'=1,'b'=2,'c'=3,'d'=4);
$arr_keys = array_keys($arr);
$key = array_pop($arr_keys);
$value = $arr[$key];
?

I benchmarked array_keys() function and it is very slow on big arrays
since PHP has to build the array.


benchmark this:

end($arr);
list($key, $value) = each($arr);


Thanks! that benchmarks with normal speed.. :-)

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



[PHP] Re: array_pop() with key-value pair ???

2007-02-16 Thread Eli

Mikey wrote:

I guess you have tried foreach?

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


No.. loop should not be necessary when you want to take only the first 
or the last element in the array.
Better using array_pop() array_shift() reset() end() and each() 
functions for better run times.


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



[PHP] Re: Extending DOMNode

2007-02-15 Thread Eli

Rob Richards wrote:
Due to the internals of the DOM extension, you need to register the 
class types that are actually instantiated and not the underlying base 
DOMNode class. Unfortunately in your case this means you need to 
register all of those classes separately.


$dom-registerNodeClass('DOMElement','MyDOMNode');
$dom-registerNodeClass('DOMAttr','MyDOMNode');
$dom-registerNodeClass('DOMText','MyDOMNode');
...


Not good... :-(

?php
class MyDOMNode extends DOMNode {
public $x = 100;
}

$dom = new DOMDocument();
$dom-registerNodeClass('DOMElement','MyDOMNode');
?

PHP Fatal error:  DOMDocument::registerNodeClass(): Class MyDOMNode is 
not derived from DOMElement.


So I have to extend DOMElement and register MyDOMElement. But all my 
nodes should be also based on MyDOMNode.
Problem is that in PHP you can only extend one class in a time, so you 
cannot build your own class-tree which extends a base class-tree of DOM. :-/


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



Re: [PHP] Re: Extending DOMNode

2007-02-15 Thread Eli

Jochem Maas wrote:

maybe the runkit extension can help - no idea how big it might explode in your
face if you try to hack the DOM* stuff with runkit :-)

you never stated why you want to extend all the DOM classes, maybe there
is a different way of achieving what you want (i.e. without going through the
hassle of what you seem to have to do at the moment)


I want to add a common function to all nodes extended from DOMNode (e.g 
DOMElement, DOMText, DOMAttr, etc), and also keep the code maintainable 
so changing the common function will not force me to do in 10 places [I 
don't want to create a global function for this].


-thanks!

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



[PHP] array_pop() with key-value pair ???

2007-02-15 Thread Eli

Hi,

Why isn't there a function that acts like array_pop() returns a pair of 
key-value rather than the value only ?


Reason is, that in order to pop the key-value pair, you do:
?php
$arr = array('a'=1,'b'=2,'c'=3,'d'=4);
$arr_keys = array_keys($arr);
$key = array_pop($arr_keys);
$value = $arr[$key];
?

I benchmarked array_keys() function and it is very slow on big arrays 
since PHP has to build the array. While array_pop() can be acceleraed by 
the guts of PHP engine.


-thanks

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



[PHP] Re: array_pop() with key-value pair ???

2007-02-15 Thread Eli
More over.. PHP seems to be quiet slow when dealing with array_shift() 
array_unshift(), but it is much faster with array_pop() array_push(). I 
am not familiar with the PHP internals, but why not add a pointer to the 
 start and end of the array?


Good word can be said on PHP that accelerated at least count() function..

Maybe I require too much.. PHP is a rapid development scripting 
language.. not a massive optimized programming language.. :-/




Eli wrote:

Hi,

Why isn't there a function that acts like array_pop() returns a pair of 
key-value rather than the value only ?


Reason is, that in order to pop the key-value pair, you do:
?php
$arr = array('a'=1,'b'=2,'c'=3,'d'=4);
$arr_keys = array_keys($arr);
$key = array_pop($arr_keys);
$value = $arr[$key];
?

I benchmarked array_keys() function and it is very slow on big arrays 
since PHP has to build the array. While array_pop() can be acceleraed by 
the guts of PHP engine.


-thanks


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



[PHP] Object ID

2007-02-14 Thread Eli

Hi,

How can I get the object ID number of each Object in PHP (v.5.2) ?

The ID number is the one produced when dumping:
?php
class A {}
class B {}
$a = new A();
$b = new B();
var_dump($a);
var_dump($b);
?
=== output:
object(A)#1 (0) {
}
object(B)#2 (0) {
}

I do not want to buffer and parse the dumped string... Is there a nicer way?

-thanks!

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



Re: [PHP] Object ID

2007-02-14 Thread Eli

Roman Neuhauser wrote:

How can I get the object ID number of each Object in PHP (v.5.2) ?


http://cz2.php.net/manual/en/function.spl-object-hash.php


Thanks!!! That is exactly what I need... :-)

?php
class A {}
class B {}
$a = new A();
$b = new B();
var_dump(spl_object_hash($a));
var_dump(spl_object_hash($b));
?
=== output:
string(32) eaa76ef5378142caec7b40b56e4b6314
string(32) 6168ec2b9db13132570a79ef04104e3c

-thanks!

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



Re: [PHP] Object ID

2007-02-14 Thread Eli

Every dump of the same node will produce the same #id.
Cloned object, is a separated new object which will have a different id.
The spl_object_hash function produces such an id too (32 hex chars), 
which doesn't change if you change the object members.



Richard Lynch wrote:

I suspect that's not an absolute ID, but just an ID for that
particular dump.  So it has no applicability beyond that dump...


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



Re: [PHP] Object ID

2007-02-14 Thread Eli

Hmm.. sorry.. just checked it now, and you're right..

The #id in the dump and the hash given by spl_object_hash() give a 
unique ID among the objects instantiated in your process..
If you unset some of the objects, and re-create new instances of them, 
you may get the SAME ids you had before..


The better is might be by giving a custom id like:
$ID = md5(microtime());


Eli wrote:

Every dump of the same node will produce the same #id.
Cloned object, is a separated new object which will have a different id.
The spl_object_hash function produces such an id too (32 hex chars), 
which doesn't change if you change the object members.



Richard Lynch wrote:

I suspect that's not an absolute ID, but just an ID for that
particular dump.  So it has no applicability beyond that dump...


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



[PHP] Extending DOMNode

2007-02-14 Thread Eli

Hi,

I want to add some functionality to all classes derived from DOMNode.
I tried:

?php
class MyDOMNode extends DOMNode {
public $v = 10;
function __construct() {}
}

$dom = new DOMDocument();
$dom-registerNodeClass('DOMNode','MyDOMNode');

$dom-loadXML('roota//root');
echo $dom-firstChild-v;  #-- not outputs 10
?

But I get the notice:
PHP Notice:  Undefined property:  DOMElement::$v in ...

I want the extension to be valid for all DOM nodes that are derived from 
DOMNode, such as DOMElement, DOMAttr, DOMNodeList, DOMText, etc...

I try not to extend all the classes one by one.

How can I do that?

-thanks, Eli

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



[PHP] Array to Object

2007-02-13 Thread Eli

Hi,

Having this array:
$arr = array(
'my var'='My Value'
);
Notice the space in 'my var'.

Converted to object:
$obj = (object)$arr;

How can I access $arr['my var'] in $obj ?

-thanks!

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



[PHP] XPath question

2007-02-05 Thread Eli

Hi,

ns:root i=0
tag
ns:node i=1/
/tag
ns:anothernode i=2
ns:notme i=3
ns:meneither i=4/
/ns:notme
anothertag/
/ns:anothernode
/ns:root

I need to retrieve a list of all the INNER ns:* nodes (not the root 
i=0 node), that do not have an ancestor of any ns:* node but the root 
ns:root i=0 node.

In other words: get all ns:* nodes with i in {1,2}.

-thanks!

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



Re: [PHP] include file identifier

2007-02-05 Thread Eli

Richard Lynch wrote:
 On Sat, February 3, 2007 7:05 pm, Eli wrote:
 Does any included file in PHP have a unique identifier? (like a stack
 of
 includes identifier).

 Down in the guts of PHP source, there may be some kind of file handler
 which is unique...

Actually, that's what I need.
I want to know which instance of the file is running.. __FILE__ only 
gives the filename, but if the file is included in itself, there's no 
way to distinct which instance of them is currently running..


The base reason for this is storing some extra environment data on each 
file included..



-thanks, Eli

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



[PHP] Re: XPath question

2007-02-05 Thread Eli

Eli wrote:

Hi,

ns:root i=0
tag
ns:node i=1/
/tag
ns:anothernode i=2
ns:notme i=3
ns:meneither i=4/
/ns:notme
anothertag/
/ns:anothernode
/ns:root

I need to retrieve a list of all the INNER ns:* nodes (not the root 
i=0 node), that do not have an ancestor of any ns:* node but the root 
ns:root i=0 node.

In other words: get all ns:* nodes with i in {1,2}.



Solved. :-)

$XPathQuery = /*//ns:*[not(ancestor::ns:*[ancestor::ns:*])]

-thanks

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



[PHP] include file identifier

2007-02-03 Thread Eli

Hello,

Does any included file in PHP have a unique identifier? (like a stack of 
includes identifier).


If the files names are different, then __FILE__ can be used as an 
identifier. But if a file was included by itself, then __FILE__ is the 
same, tho there are 2 different includes of the same file.


Example:
=== a.php
?php
echo \nRunning .__FILE__. (id=X)!\t;
if (!$visited) {
echo You are visiting here!;
$visited = true;
include(__FILE__);
}
else {
echo You have been already visiting here! (Bye);
}
?

-thanks, Eli

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



Re: [PHP] include file identifier

2007-02-03 Thread Eli

Robert Cummings wrote:

Looking at the code above... it would seem you want:

include_once()

It's not the idea..

I'm not trying to make that code work, I want to know which exact 
include (of the same file) does what..


Say you got a loop of self-include:
e.g:
=== a.php
?php
echo \nRunning .__FILE__. (id=X)!\t;
if ($visited5) {
echo You are visiting here!;
$visited++;
include(__FILE__);
}
else {
echo That's enough! Bye!;
}
?

In (id=X)!.. what's the X? You may say you can use $visited as an 
identifier, but it's not the point I mean.. I want a global include file 
identifier, that is not dependent on other variables.


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



[PHP] Combining 2 DOM XML nodes from different documents

2007-02-01 Thread Eli

Hi,

?php
$x1 = EOT
a p1=v1
a1 p1=vv1/
/a
EOT;
$x2 = EOT
b p1=v1
b1 p1=vv1/
/b
EOT;

$X1 = new DOMDocument();
$X1-loadXML($x1);
$X2 = new DOMDocument();
$X2-loadXML($x2);

$X1-firstChild-appendChild($X2-firstChild-cloneNode(true));

echo htmlspecialchars($X1-saveXML());
?


I got an error in the line $X1-firstChild-appendChild...
[01-Feb-2007 22:20:29] PHP Fatal error:  Uncaught exception 
'DOMException' with message 'Wrong Document Error' in 
E:\www\mysite\htdocs\combine.php:17


How can I combine these 2 XMLs to get:
a p1=v1
a1 p1=vv1/
b p1=v1
b1 p1=vv1/
/b
/a

-thanks! :-)

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



[PHP] Re: Combining 2 DOM XML nodes from different documents

2007-02-01 Thread Eli

?php
$x1 = EOT
a p1=v1
a1 p1=vv1/
/a
EOT;
$x2 = EOT
b p1=v1
b1 p1=vv1/
/b
EOT;

$X1 = new DOMDocument();
$X1-loadXML($x1);
$X2 = new DOMDocument();
$X2-loadXML($x2);

$X1-firstChild-appendChild($X2-firstChild-cloneNode(true));

echo htmlspecialchars($X1-saveXML());
?


I got an error in the line $X1-firstChild-appendChild...
[01-Feb-2007 22:20:29] PHP Fatal error:  Uncaught exception 
'DOMException' with message 'Wrong Document Error' in 
E:\www\mysite\htdocs\combine.php:17


Found the answer. Should use DOMDocument-importNode() method, and just 
append the imported node.


-thanks!

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



Re: [PHP] Bug? (_ENV in PHP v5.2.0)

2007-01-16 Thread Eli

Frank M. Kromann wrote:

Hi Eli,

Check variable_order in php.ini
(http://us2.php.net/manual/en/ini.core.php#ini.variables-order) if the E is
missing you will not get any environment variables.

- Frank



Thanks, Frank.. That worked! :-)

-thanks, Eli

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



[PHP] Bug? (_ENV in PHP v5.2.0)

2007-01-15 Thread Eli

Hi,

System:
Win32
PHP 5.2.0
Apache 2.0.54 (PHP in CGI mode)

CGI vars are not automatically loaded into $_ENV global array. Only when 
calling getenv('var'), just then the variable appears in $_ENV.
Besides, it seems that the env vars are loaded automatically into 
$_SERVER. And $HTTP_ENV_VARS is always NULL.



?php
echo before getenv...;
echo br\$_ENV: ; var_dump($_ENV);
echo br\$HTTP_ENV_VARS: ; var_dump($HTTP_ENV_VARS);

getenv('SERVER_PROTOCOL');
echo hrafter getenv...;
echo br\$_ENV: ; var_dump($_ENV);
echo br\$HTTP_ENV_VARS: ; var_dump($HTTP_ENV_VARS);
?

=== output:
before getenv...
$_ENV: array(0) { }
$HTTP_ENV_VARS: NULL

after getenv...
$_ENV: array(1) { [SERVER_PROTOCOL]= string(8) HTTP/1.1 }
$HTTP_ENV_VARS: NULL


Is it a bug? Or this is the way it should work?


-thanks, Eli

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



[PHP] Extending 'include' behavior in a function

2007-01-10 Thread Eli

Hi,

I want to create a function that does some stuff, and then includes 
another file in the place from where it was called. The idea is to run 
the included file not in the function, but in the place of the caller in 
the caller's environment (not in the function environment).

For example:

?php
function includeIt($file) {
$name = Debora;
trigger_error(Include START: '$file');
include($file); // This include should run in the environment
// of the caller, from the place it was called.
trigger_error(Include END: '$file');
}

$name = Joe;
echo Hello!;
includeIt(msg.inc); // The file should be included here, not in the
// 'includeIt' function.
// Say the file 'msg.inc' uses the $name
// variable from the caller's environment.
// In this case, I want it to say hello to Joe,
// and not to Debora.
echo Bye!;
?

-thanks, Eli.

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



Re: [PHP] Extending 'include' behavior in a function

2007-01-10 Thread Eli

Jochem Maas wrote:

short of playing around with the global keyword
(which won't work when you call includeIt() from
another function)) your pretty much stuck.

basically imho you need to rethink what it is your trying to do.

function have their own scope for a reason; maybe consider using
an array argument like so:

function incIt($file, $args = array())
{
extract((array)$args);
include $file; // don't forget some error checking
}

function includeIt($file, $args = array())
{
// bla
incIt($file, $args);
// more bla
}

I broke it down into 2 functions to avoid local variables
being overridden in includeIt() [by the call to extract].


In addition to your solution, it is needed to transfer the variables by 
reference.


Your solution is good when you know what variables you want to transfer 
ahead, and then make a list of them. But if I want to transfer all the 
variables in the current environment scope?


-thanks, Eli.

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



[PHP] Re: string lenght?

2006-02-12 Thread Eli

William Stokes wrote:

How can I test whether a string is 1 or 2 digits long?


You can use regular expressions:

preg_match('/^\d{1,2}$/',$str);

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



[PHP] PHP multi-threading ?

2006-02-12 Thread Eli

Hi,

Is PHP gonna support multi-threading (not multi-processing) capabilities 
in the future?
Even just for the CLI (and CGI) mode.. It would be very helpful to use 
PHP as server scripting language on linux (rather than perl). ;-)


Where can I check the road map of PHP development?

-thanks

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



Re: [PHP] PHP multi-threading ?

2006-02-12 Thread Eli

Chris wrote:


Is this what you're after?

http://www.php.net/pcntl

specifically http://www.php.net/pcntl_fork

Sorry, but no... This is multi-processing, not multi-threading. And it's 
supported on CLI mode already and not on windows.



Where can I check the road map of PHP development?



http://blog.justbe.com/articles/2005/11/23/php6-minutes-php-developers-meeting-in-paris 



http://www.php.net/~derick/meeting-notes.html


I'm looking for features list to support in the future..
Anyways, nothing is mentioned on multi-threading there..

Thanks!

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



[PHP] Re: string size in bytes

2006-02-12 Thread Eli

benifactor wrote:

also i need to know how to find out how fast a page renders

example;

page rendered in 1.114 seconds



?php
$start_time = microtime(true);

// ... code goes here ... //

$end_time = microtime(true);
$duration = $end_time - $start_time;
echo page rendered in $duration seconds;
?

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



[PHP] Using API in other languages

2006-02-04 Thread Eli

Hi,

I have a class in PHP which offers some API functions. I want to access 
this API with other languages (such as C/C++, Java, Perl, etc), so the 
functions will run from PHP.

How can I do that?

-thanks.

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



[PHP] Re: Arrays

2006-02-04 Thread Eli

Philip W. wrote:
Sorry if this question seems stupid - I've only had 3 days of PHP 
experience.


When using the following string format, I get an error from PHP.

$text['text'] = String Text ;

Can someone help me?


This seems ok and should not give any error. Mabye the error is of 
something else.

What's the error you get?

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



[PHP] Re: Using API in other languages

2006-02-04 Thread Eli
Is there any other way of doing this without technology like web 
services? mabye a glue extension between those languages?



Rory Browne wrote:
 I could be wrong on this, but I think your best hope is something
 using web services like SOAP, or XML-RPC.

 On 2/4/06, Eli [EMAIL PROTECTED] wrote:

Hi,

I have a class in PHP which offers some API functions. I want to access
this API with other languages (such as C/C++, Java, Perl, etc), so the
functions will run from PHP.
How can I do that?

-thanks.


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



[PHP] Running snippets from within PHP

2006-01-31 Thread Eli

Hi,

How can I run non-PHP code snippets from within PHP?
For example: Is it possible to include a C++ code snippet within PHP and 
run it as it was a regular include?
I know there's a solution using exec() and such, but I want to run the 
snippets like inline code.


-thanks, Eli

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



[PHP] Session creation time

2005-09-19 Thread Eli
How can I get the first creation time of a session (the time a session 
was first started)?


-thanks.

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



Re: [PHP] Re: dynamic object instances

2005-08-10 Thread Eli

Thomas Angst wrote:
 Thanks for you answer, but sorry, I do not understand your hint. I tried
 this code:
 class test {
var $txt;
function test($txt) { $this-txt = $txt; }
function out() { echo $this-txt; }
 }
 $obj = call_user_func_array(array('test', 'test'), array('foobar'));
 $obj-out();
 But I'm getting an error while accessing the $this pointer in the
 constructor.

This will not work, since it is like calling a static class method, and 
$this is not allowed to be used in static methods.


I solved this with eval() function.
?
$obj_eval=return new $class(;
for ($i=0; $icount($args); $i++)
   $obj_eval.=\$args[$i],;
$obj_eval=substr($obj_eval,0,-1).);;
$obj=eval($obj_eval);
?

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



Re: [PHP] Re: dynamic object instances

2005-08-10 Thread Eli

Jochem Maas wrote:

Eli wrote:

?
$obj_eval=return new $class(;
for ($i=0; $icount($args); $i++)
   $obj_eval.=\$args[$i],;
$obj_eval=substr($obj_eval,0,-1).);;
$obj=eval($obj_eval);
?



I believe that this is the kind of clever, evil stuff the OP was trying 
to avoid...
(evil - eval :-) - besides eval is very slow - not something you (well 
me then) want to
use in a function dedicated to object creation which is comparatively 
slow anyway
(try comparing the speed of cloning and creating objects in php5 for 
instance


regardless - nice one for posting this Eli - I recommend anyone who 
doesn't understand

what he wrote to go and figure it out, good learning material :-)



You're right that using eval() slows.. But using the _init() function as 
you suggested is actually tricking in a way you move the constructor 
params to another function, but the initialization params should be sent 
to the constructor!


I guess that it would be better if PHP will add a possibility to 
construct a dynamic class with variant number of params... ;-)


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



[PHP] Sockets and SOAP

2005-08-10 Thread Eli

Hi,

I want to implement a client-server relationship between a PHP server 
application and another .NET client application.
I want the connection to be kept alive, so I use the socket routine 
running till disconnecting. I also want to transfer the data between the 
server and client using SOAP envelopes.


How can I send SOAP envelopes (requests  responses) through the same 
socket?
If it's not possible with PHP's SOAP library, is it possible with other 
SOAP library for PHP (such PEAR:SOAP)?


-thanks, Eli

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



[PHP] Server-Client connection via TCP port with PHP

2005-08-09 Thread Eli

Hi,

I got a PHP program on my server. I want to open a live TCP port 
connection between my server to a client (client is developed in .NET, 
not regular HTTP browser).

How can I do this using PHP?

-thanks in advance!

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



[PHP] variable object creating

2005-06-21 Thread Eli

Hi,

I want to create an object in a form that I get the class name and its 
parameters, and I need to create that object...

How can this been done?

i.e:
$classname = MyClass;
$construct_params = array(param1,param2,param3);
/* Now create the object with the given classname and params... how? */

-thanks, Eli

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



[PHP] gettext - multi text domains ?

2005-04-26 Thread Eli
Hi,
I haven't yet started with gettext, but I consider to use it.
Is it possible to use several text domains of gettext together?
For example: I got 2 basic GUIs with their own text domains. I want to 
combine both the GUIs together, so is it possible to use the text 
domains of both the GUIs simultaneous?
If yes, when I get an expression key that exists in both text domains, 
with which text domain it will be translated?

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


[PHP] JavaScript - object property

2005-04-26 Thread Eli
Hi,
I know this is not the forum, but I googled and couldn't find it, so 
please try to help me with this.

/*/
function MyCls(name)
{
   this.name=name;
}
function SayHi()
{
   alert('Hi, '+this.name+'!');
}
var obj=new MyCls('PHP');
obj.name='JavaScript';  //this will call SayHi() function
/*/
I have a class in JS with a property variable in it. How can I execute a 
function when the property value is changed?

Sorry it's off-topic..
-thanks, Eli
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Multilingual Web application - how to?

2005-04-08 Thread Eli
Denis Gerasimov wrote:
I need to develop a multilingual web site and I am looking for the best way
of handling this task. There are three main issues I know:
Mabye consider of using gettext..
http://www.php.net/gettext
BTW: why doesn't Smarty support gettext?
 How can gettext be implemented into Smarty (with simplier syntax)?
-thanks, Eli
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: mysql regexp select questions

2005-04-07 Thread Eli
Andras Kende wrote:
I would like to do the following:

mysql db:
andrew
anthony
joe
janice
john
simon

sql_query ( select names .

I would need only the distinct first character from the query
result would be: a,j,s
I think maybe its REGEXP but never did it before...
Thanks!!
Andras Kende

Try the query (no REGEXP):
SELECT DISTINCT SUBSTRING(names,0,1) FROM .
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Smart Trimming of UTF-8 Entities for Database

2005-04-07 Thread Eli
C Drozdowski wrote:
I need to be able to store UTF-8 characters from a form into a MySQL 
table. But I need to support pre-UTF-8 MySQL ( 4.1).

So I'm converting UTF-8 characters into their numeric entities (e.g. ñ = 
#241;).

The problem is that if the user enters a character that gets converted 
to an entity, the string might end up being longer than the field 
definition in the table allows.

For example, if I have a varchar(5) column and try to insert señor 
(which has been converted to sen#241;or), I get sen# in the table 
which is useless.

Has anyone dealt with this and if so how?
Thanks in advance for any advice, or pointers to any code that deals 
with this.
You first need to convert to binary charset, and then to the real 
charset. Do not convert from current charset to the real charset ahead, 
you may cause a data loss.
BEFORE converting - *backup* your databases !!!

http://dev.mysql.com/doc/mysql/en/charset-conversion.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: pasring complex string question

2005-04-07 Thread Eli
Webmaster wrote:
Hello, 

i have a string looking like this.
 

## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V (VALUE3)/T
(KEY3)|| 

 

 

I know want to separete it in to keys and values and insert them into an
array.
Note that /T always shows that teh upcoming value in() is a Key and that /V
always is a Value. And that the set can be flipped.
 

Thank you very much for helping.
Mirco Blitz

It seems you complex yourself too much.. ;)
Try using regexp with the 'e' modifier:
?php
$data=## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V 
(VALUE3)/T (KEY3)||;

$data_array=array();
preg_replace(
array(
/\#\#\s*/T\s*\(([^\)]*)\)\s*\V\s*\(([^\)]*)\)\s*\|\|/e,
/\#\#\s*/V\s*\(([^\)]*)\)\s*\T\s*\(([^\)]*)\)\s*\|\|/e
),
array(
\$data_array['\\1']='\\2';,
\$data_array['\\2']='\\1';
),
$data
);
print_r($data_array);  //see if you get it as expected
?
I believe there's an easier way to store your data as strings (like 
serialize), so why not using them?!
see alse: http://www.php.net/serialize

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


[PHP] Re: pasring complex string question

2005-04-07 Thread Eli
Eli wrote:
Webmaster wrote:
Hello,
i have a string looking like this.
 

## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V (VALUE3)/T
(KEY3)||
 

 

I know want to separete it in to keys and values and insert them into an
array.
Note that /T always shows that teh upcoming value in() is a Key and 
that /V
always is a Value. And that the set can be flipped.

 

Thank you very much for helping.
Mirco Blitz

It seems you complex yourself too much.. ;)
Try using regexp with the 'e' modifier:
?php
$data=## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V 
(VALUE3)/T (KEY3)||;

$data_array=array();
preg_replace(
array(
/\#\#\s*/T\s*\(([^\)]*)\)\s*\V\s*\(([^\)]*)\)\s*\|\|/e,
/\#\#\s*/V\s*\(([^\)]*)\)\s*\T\s*\(([^\)]*)\)\s*\|\|/e
),
array(
\$data_array['\\1']='\\2';,
\$data_array['\\2']='\\1';
),
$data
);
print_r($data_array);  //see if you get it as expected
?
I believe there's an easier way to store your data as strings (like 
serialize), so why not using them?!
see alse: http://www.php.net/serialize
Sorry... a little correction:
?php
$data=## /T (KEY1)/V (VALUE1)|| ## /T (KEY2)/V (VALUE2)|| ## /V 
(VALUE3)/T (KEY3)||;

$data_array=array();
preg_replace(
array(
/\#\#\s*\/T\s*\(([^\)]*)\)\s*\/V\s*\(([^\)]*)\)\s*\|\|/e,
/\#\#\s*\/V\s*\(([^\)]*)\)\s*\/T\s*\(([^\)]*)\)\s*\|\|/e
),
array(
\$data_array['\\1']='\\2';,
\$data_array['\\2']='\\1';
),
$data
);
print_r($data_array);  //see if you get it as expected
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Extern Executions (Perl)

2005-04-07 Thread Eli
Hi,
It seems more like a problem in Perl than PHP.. so sorry if this is 
asked in the wrong list, but I believe there are also Perl gurus among 
the list members.. ;)

I have a perl script which from it I externally execute a PHP script 
with some parameters.
When running the perl program throu unix shell, then perl executes the 
PHP program as expected, and returns its output.
When running the perl program throu Apache (using cgi-bin on a browser), 
then perl opens the PHP file for reading and doesn't execute the PHP 
script, and returns the PHP code of the script.

The Perl line trying to execute the PHP script is:
open (PIPE,./my_prog.php $arg1 $arg2 |);
while (PIPE)
  $res=$res.$_;
print got:\n,$res;
Does anyone have any clue why Perl behaves differently on different 
enviorments?
OR: does anyone have a suggestion for a stable solution?

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


[PHP] Validating a Blogger Template using PHP

2005-04-02 Thread Eli
Hi,
We want to validate a blogger template structure using PHP. We thought 
about using XML schema on that, but it's not going well for us..

Do you know about existing tools that validate Blogger Template 
structure? Or of a way how to validate the Blogger Template?

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


Re: [PHP] Mod Rewrite help

2005-03-28 Thread Eli
Brian Dunning wrote:
How would I mod_rewrite a request for /baseball.htm into
/query.php?q=baseball?

This should be doing it as far as I can tell, but for some reason it's 
not...

RewriteEngine on
RewriteRule /^(.+).htm$ /query.php?q=$1
RewriteEngine on
RewriteRule ^/(.+)\.htm$ /query.php?q=$1
But note this isn't good.. since say if you got a regular page 
/index.htm then it will be rewritten into /query.php?q=index so what you 
better do is having a prefix of a 'virtual' directory, like was 
suggested before 'sport'... and make it like this:

RewriteEngine on
RewriteRule ^/sport/(.+)\.htm$ /query.php?q=$1
-Eli.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Validating XML structure with PHP

2005-03-28 Thread Eli
Hi,
I want to validate an XML structure using PHP.
I thought of using PHP's DOM and XSD or DTD for validation. This does 
the job ok, except on invalid XML structure I get the same error code. 
What I want is to point exactly why the XML structure is invalid. I know 
there's also an error message that gives a bit more precision on the 
cause, but it's not something I can show the user.

Is there another way to validate XML structure (that can give a precise 
error cause, like missing element, invalid element value, etc)?

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


[PHP] Private Cache Headers in IE and Mozilla

2005-03-19 Thread Eli
Hi,
I want to cache a PHP page privately for a week.
What headers should I send to make it work both in Mozilla and IE?
I have set these headers, but those work only for IE:
?php
$max_age=604800;
header(Date: .gmdate(D, d M Y H:i:s,time()));
header(Cache-Control: private);
header(Cache-Control: max-age=$max_age,false);
header(Expires: .gmdate(D, d M Y H:i:s,time()+$max_age). GMT);
?
What are the correct headers?
-thanks, Eli
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] is_a() against instanceof

2005-03-15 Thread Eli
Hi,
PHP5 uses the 'instanceof' keyword instead of the deprecated is_a() 
function.
But there's a big difference between the two:
- is_a($cls,ClassName)  *doesn't require* from ClassName to be 
declared, and return false when ClassName is not declared.
- ($cls instanceof ClassName)  *requires* from ClassName to be declared, 
and generates a fatal error when ClassName is not declared.

Since is_a() is deprecated.. is there a way to use instanceof exactly 
like is_a() function (so it will not make an error when the class is not 
declared)?

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


[PHP] Re: Can I use ftp_put to bypass upload_max_filesize?

2005-03-15 Thread Eli
Sed wrote:
Is it somehow possible, to use ftp_put to upload a file bigger than the
upload_max_filesize is set in the php.ini? (eg. upload 100Mb while
upload_max_filesize is set to 16MB)
You will have also to consider the browser's timeout limit. Uploading a 
100MB file via HTTP POST will probably take quite a long time that the 
browser will timeout and interrupt the transfer.

I got a thought, but didn't try to check it out:
If there's a way to split a file to small chunks (i.e 2MB a chunk), then 
you can use JS Remote Scripting (HTTPRequest) to upload the chunks one 
by one, and then append all chunks on server side and you get the 100MB 
file. This way you can also display a progress bar of uploading. Of 
course the chunks will be transffered like packets (in TCP), so each 
chunk will have an header that relates it to the original file.
The part that is not well cleared to me is whether is possible to split 
a file into chunks using JS.
What do you think?

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


[PHP] Calling a function from the parent class

2005-03-15 Thread Eli
Hi,
?php
class A
{
   public function func() { echo A; }
}
class B extends A
{
   public function func() { echo B; }
}
$cls=new B();
$cls-func();  //echo: B
?
How can I call func() of class A from $cls object (that when I call 
func() it will echo A and not B)?

Changing functions names or declaring another function in class B that 
will call parent::func() are not good for me.

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


[PHP] Re: is_a() against instanceof

2005-03-15 Thread Eli
Jason Barnett wrote:
Eli wrote:
...
- is_a($cls,ClassName)  *doesn't require* from ClassName to be
declared, and return false when ClassName is not declared.
...
Try is_subclass_of()
http://php.net/manual/en/function.is-subclass-of.php
is_subclass_of() is not exactly like is_a(), in that it will return 
false if the object is exactly from the class.

$cls=new ClassName();
var_dump(is_subclass_of($cls,ClassName));  //dumps: FALSE!
var_dump(is_a($cls,ClassName));  //dumps: TRUE!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP RegExp and HTML tags attributes values etc...

2005-03-10 Thread Eli

Yup.. that was a good point.. ;)
Take a look at this example:
?php
function tag_rep($tag)
{
   return 
reg_replace('/(?!\)(\S+)\s*=\s*(?![\'])([^\s\']+)(?![\'])/','\1=\2',$tag);
}

$html=p class=MsoNormal id=parfont size=3 face=\Comic Sans 
MS\span lang=NL style='font-size:12.0pt;font-family:\Comic Sans 
MS\'a 
href=http://www.php.net/index.phpnbsp;key=valuenbsp;/a/span/font/p;

$improved_html=preg_replace('/\(.*)\/Ue','.tag_rep(\1).',$html);
echo str_replace(\',',$improved_html);
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP RegExp and HTML tags attributes values etc...

2005-03-10 Thread Eli
Sorry for the spam.. here it is:
?php
function tag_rep($tag)
{
   return 
preg_replace('/(?!\)(\S+)\s*=\s*(?![\'])([^\s\']+)(?![\'])/','\1=\2',$tag);
}

$html=p class=MsoNormal id=parfont size=3 face=\Comic Sans 
MS\span lang=NL style='font-size:12.0pt;font-family:\Comic Sans 
MS\'a 
href=http://www.php.net/index.phpnbsp;key=valuenbsp;/a/span/font/p;

$improved_html=preg_replace('/\(.*)\/Ue','.tag_rep(\1).',$html);
echo str_replace(\\',',$improved_html);
?
:)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] shell script - disable log output

2005-03-09 Thread Eli
Hello...
I'm writing a shell script that uses error_log function to log some 
data, but it echos the error message to the output without logging the 
message to the log file.

Code I use (php5 on unix):
*
#!/usr/local/php/bin/php -q
?php
error_log(My error message);
?
*
OUTPUT:
$ test.php
My error message
$
How can I prevent the error messages from being echoed to the client?
-thanks, Eli
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Best way to validate a date

2005-03-09 Thread Eli
David Bevan wrote:
Hi all,
I'm looking to validate a date submitted through a
form and I cannot decide which would be the best way
to do it.  The form of the date needs to be:
-MM-DD.
At the moment I'm torn between using a regex,
something like: 20[\d][\d]-[0-1][\d]-[0-3][\d]
or using the checkdate() function.
Does anyone have any pros and/or cons to implement one
method over the other or other methods you may have
used?
Thanks,
David
Better use checkdate, since it checks if the date really exists (not 
just well formatted).
Mabye do something like this:

list($check_year,$check_month,$check_day) = explode(-,$date);
if (checkdate($check_month,$check_day,$check_year))
echo Date is valid;
else
echo Date is not valid;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: shell script - disable log output

2005-03-09 Thread Eli
I suppose error_log(My error message, 3, /dev/null) would work.
I cannot change the error_log() params, since it is cored in extern lib 
I use.
Is there a way to prevent the default error_log() from being outputed?

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


Re: [PHP] shell script - disable log output

2005-03-09 Thread Eli
John Nichel wrote:
Try
@error_log ( My error message );
Don't know if it will work, but it's worth a shot.
Checked. That's not working, since the @ operator prevents logging of 
errors/warnings/notices that caused by the expression following, but 
doesn't prevent from the expression to be executed.

Besides, I can't change the syntax of the error_log which is used with 
defaults: error_log(MSG);

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


[PHP] Re: shell script - disable log output

2005-03-09 Thread Eli
Jason Barnett wrote:
Eli wrote:
I suppose error_log(My error message, 3, /dev/null) would work.

http://php.net/manual/en/ref.errorfunc.php#ini.error-log
try:
ini_set('error_log', null)
Doesn't work either.. :( but thanks for trying..
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] shell script - disable log output

2005-03-09 Thread Eli
John Nichel wrote:
Try output buffering and dumping the buffer to /dev/null?
From all the suggestions the script now looks like this:
#!/usr/local/php5/bin/php -q
?php
ob_start();
ini_set(error_log,null);
@error_log(My error message);
ob_end_clean();
?
But it still output the error to the screen.. :(
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] shell script - disable log output

2005-03-09 Thread Eli
John Nichel wrote:
Eli wrote:
 From all the suggestions the script now looks like this:
#!/usr/local/php5/bin/php -q
?php
ob_start();
ini_set(error_log,null);
@error_log(My error message);
ob_end_clean();
?
But it still output the error to the screen.. :(
I saw someone suggest this
error_log ( My error message, 3, /dev/null );
And that works fine on my machine...have you tried that?
Basically, I cannot change the line of the error_log() since it used in 
extern lib. I can only add lines before the include (that calls it) to 
prevent this, or call php with some other params (on the first exec line 
#!/usr/...), but nothing helps so far for this situation.

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


Re: [PHP] shell script - disable log output

2005-03-09 Thread Eli
Richard Lynch wrote:
I'm writing a shell script that uses error_log function to log some
data, but it echos the error message to the output without logging the
message to the log file.

the log file...
*WHAT* log file?
A shell script has no pre-determined log file, really.
Actually, it's almost for sure STDOUT at that point, or maybe STDOUT, but
I doubt it.  If you were coding PHP engine and needed to send error output
somewhere under shell circumstances, you'd think STDOUT would be it
right?...
So you can probably re-direct 2 (STDOUT) to somewhere to get the error_log
output where you want it.
I think in most shells that turns into:
test.php 2 /var/log/test
YMMV
It's up to you to figure out re-directs in your shell of choice.  Good luck.
You should probably use can use set_error_handler to trap errors -- though
that will not catch error_log output, I don't think.
You can also use set_error_reporting() to get rid of errors entirely,
though that's not recommended.
I don't really need it to log into a file, but I wanted to prevent it 
from echoing to the screen.

So I guess there's no way to prevent from error_log() (using defaults) 
to echo to the screen (STDOUT).
error_reporting() affects on errors produced by PHP itself. I tried to 
set it to 0 before the call, but it didn't help.
set_error_handler() affects on trigger_error() and not on error_log().

It seems that the extern lib I use should use trigger_error() (or 
user_error()) function instead, which is the traditional way to report 
user-defined errors.

Thanks for your help all...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP RegExp and HTML tags attributes values etc...

2005-03-09 Thread Eli
BlackDex wrote:
Hello ppl,
I have a question about regex and html parsing.
I have the following code:
---
p class=MsoNormalfont size=3 face=Comic Sans MSspan lang=NL
style='font-size:12.0pt;font-family:Comic Sans MS'nbsp;/span/font/p
---
It laks some quotemarks.
I want to change it to:
---
p class=MsoNormalfont size=3 face=Comic Sans MSspan lang=NL
style='font-size:12.0pt;font-family:Comic Sans MS'nbsp;/span/font/p
---
So it will have  around the attribute values...
But i can't figure out how to do that :(.
Can anyone help me with this??
Thx in advance.
Kind Regards,
BlackDex
Try:
preg_replace('/(?=\)([^]*)(\w+)=(?!\'|\)([^\s]+)(?=\s|\)([^]*)(?=\)/U','\1\2=\3\4',$html);
Hmm.. that could be a start.. and don't ask me how it works... :P
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP RegExp and HTML tags attributes values etc...

2005-03-09 Thread Eli
Eli wrote:
Try:
preg_replace('/(?=\)([^]*)(\w+)=(?!\'|\)([^\s]+)(?=\s|\)([^]*)(?=\)/U','\1\2=\3\4',$html); 

Hmm.. that could be a start.. and don't ask me how it works... :P
Well.. problem with that, is that if you got more than 1 un-escaped 
attribute in a tag, the regex will fix only the first un-escaped attribute.

for example, if $html is:
p class=MsoNormal id=parfont size=3 face=Comic Sans MSspan lang=NL
style='font-size:12.0pt;font-family:Comic Sans 
MS'nbsp;/span/font/p

In that case the id=par will remain as is...
Does anyone knows how to improve it?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: incrementing a number from a text file

2005-03-09 Thread Eli
Ross Hulford wrote:
I want to read a number from an external (txt) file and increment it.then 
save the number back on the text file.
I know this is possible but want a simple amd economical way to do this.
Try:
file_put_contents(file.txt,((int)file_get_contents(file.txt))+1);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: How can i calculate total process time?

2005-03-06 Thread Eli
M. Sokolewicz wrote:
fetch the microtime() at the top of the script, and at the bottom of the 
script you fetch it again. Subtract the first from the later, and you're 
left with the time it took. Then change it to a human-readable form, and 
you're done. You can't get closer without hacking the ZE
On top use this:
?php
$mtime = explode( ,microtime());
$starttime = $mtime[1] + $mtime[0];
?
On the end use this:
?php
$mtime = explode( ,microtime());
$endtime = $mtime[1] + $mtime[0];
echo \n\n\nhrb.round($endtime-$starttime,3). sec/b;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: The length of midi

2005-02-21 Thread Eli
Hi,
Bauglir wrote:
Does anybody know how to determine the length (in seconds) of midi melody?
There's a free library I use to fetch useful data on files such office 
files, audio, video, image, etc.
Look at:
	http://www.getid3.org

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


[PHP] mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
Hi...
I got a shared lib API written in PHP, that depends on sessions for its 
operation.
I took a prepared system in Perl that I want integrate with the shared 
lib API in PHP.

What I thought about is, to write a mediator class in Perl that will 
define the same API functions as I got in the shared lib API in PHP. I 
do not want to imitate the API functions workflow in Perl, but instead 
call the shared lib API in PHP from Perl (this way I don't have to 
maintain 2 class APIs in different languages).

I thought of making a PHP script that can run on shell and return 
serialized output of any API function in the shared lib. Then call that 
script from Perl and process the returned output in Perl.
Problem in this way is, that the shared lib in PHP uses sessions which 
are un-accessable from a shell script. And I cannot put that script on 
the web, since it returns sensitive data.
Is there a way to use sessions variables in PHP shell script (without 
reading the session file and parse it in the script)?

If anyone is familiar with any other implementation of such a mediator, 
please tell.

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


[PHP] mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
Hi...
I got a shared lib API written in PHP, that depends on sessions for its 
operation.
I took a prepared system in Perl that I want integrate with the shared 
lib API in PHP.

What I thought about is, to write a mediator class in Perl that will 
define the same API functions as I got in the shared lib API in PHP. I 
do not want to imitate the API functions workflow in Perl, but instead 
call the shared lib API in PHP from Perl (this way I don't have to 
maintain 2 class APIs in different languages).

I thought of making a PHP script that can run on shell and return 
serialized output of any API function in the shared lib. Then call that 
script from Perl and process the returned output in Perl.
Problem in this way is, that the shared lib in PHP uses sessions which 
are un-accessable from a shell script. And I cannot put that script on 
the web, since it returns sensitive data.
Is there a way to use sessions variables in PHP shell script (without 
reading the session file and parse it in the script)?

If anyone is familiar with any other implementation of such a mediator, 
please tell.

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


[PHP] Re: mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
It's quite easy to pass the session variables to the script. The problem 
with sessions and shell PHP scripts, is that PHP doesn't support 
sessions on that mode (CLI mode it is called). So, I would have to 
manualy read the session file and parse it. If anyone knows what is the 
exact function that is used to unserialize the session file, please 
tell.. and it's not the unserialize() function in PHP.

I guess that using a shell PHP script with sessions is not the solution. 
Is anybody familiar with another way to use sessions??? but not through 
web, since the script returns sensitive data.

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


  1   2   >