[PHP] Extending 'include' behavior in a function
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: -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
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] Bug? (_ENV in PHP v5.2.0)
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. \$_ENV: "; var_dump($_ENV); echo "\$HTTP_ENV_VARS: "; var_dump($HTTP_ENV_VARS); getenv('SERVER_PROTOCOL'); echo "after getenv..."; echo "\$_ENV: "; var_dump($_ENV); echo "\$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
Re: [PHP] Bug? (_ENV in PHP v5.2.0)
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] Combining 2 DOM XML nodes from different documents
Hi, EOT; $x2 = << 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: -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
EOT; $x2 = << 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
[PHP] include file identifier
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 -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file identifier
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 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] XPath question
Hi, I need to retrieve a list of all the INNER nodes (not the root i=0 node), that do not have an ancestor of any node but the root node. In other words: get all 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
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
Eli wrote: Hi, I need to retrieve a list of all the INNER nodes (not the root i=0 node), that do not have an ancestor of any node but the root node. In other words: get all 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] Array to Object
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] Object ID
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: === 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
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... :-) === 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
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
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
Hi, I want to add some functionality to all classes derived from DOMNode. I tried: registerNodeClass('DOMNode','MyDOMNode'); $dom->loadXML(''); 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] Re: Extending DOMNode
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... :-( 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
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 ???
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: 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 ???
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: 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
Re: [PHP] array_pop() with key-value pair ???
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: 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 ???
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] DOM Element default ID attribute
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
Peter Lauri wrote: This was not clear for me, do you mean: => No. Let me try to be more clear.. Say you got the element , 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
[PHP] Installing Apache + PHP on Windows
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. Options Indexes FollowSymLinks AcceptPathInfo On Order Deny,Allow Allow from all 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
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. Options Indexes FollowSymLinks AcceptPathInfo On Order Deny,Allow Allow from all 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] PHP DOM saveHTML outputs entities
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
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: שלום 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 encoding="UTF-8"?> header. Example: loadXML("שלום"); $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
Tijnema ! wrote: Did you set the UTF8 format in the html_entity_decode function? so your code would become: loadXML("שלום"); $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
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] mediator between PHP and Perl (with sessions)
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)
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)
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
[PHP] Re: mediator between PHP and Perl (with sessions)
Hi.. Thanks for your help. I searched a bit more, combined with your data, tested, and found a solution. :-) #!/usr/local/bin/php -q //initialize session: ini_set("session.use_cookies","0"); //use no session cookies session_cache_limiter(null); //use no session cache limiter session_id($sid); //set the session id as got from parameter 1 //read the session variables: echo $_SESSION["name"]; ?> -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)
Eli wrote: Hi.. Thanks for your help. I searched a bit more, combined with your data, tested, and found a solution. :-) Oops.. forgot the most important line.. #!/usr/local/bin/php -q //initialize session: ini_set("session.use_cookies","0"); //use no session cookies session_cache_limiter(null); //use no session cache limiter session_id($sid); //set the session id as got from parameter 1 session_start(); //start the session //read the session variables: echo $_SESSION["name"]; ?> -thanks, Eli -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: The length of midi
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] Re: How can i calculate total process time?
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: On the end use this: ".round($endtime-$starttime,3)." sec"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] shell script - disable log output
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 * 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
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
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
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
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
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 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
John Nichel wrote: Eli wrote: From all the suggestions the script now looks like this: #!/usr/local/php5/bin/php -q 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
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...
BlackDex wrote: Hello ppl, I have a question about regex and html parsing. I have the following code: --- --- It laks some quotemarks. I want to change it to: --- --- 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...
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: style='font-size:12.0pt;font-family:"Comic Sans MS"'> 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
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: PHP RegExp and HTML tags attributes values etc...
Yup.. that was a good point.. ;) Take a look at this example: function tag_rep($tag) { return reg_replace('/(? } $html="http://www.php.net/index.php> key=value "; $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...
Sorry for the spam.. here it is: function tag_rep($tag) { return preg_replace('/(? } $html="http://www.php.net/index.php> key=value "; $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] is_a() against instanceof
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?
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
Hi, 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
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] Private Cache Headers in IE and Mozilla
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: What are the correct headers? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mod Rewrite help
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
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] Validating a Blogger Template using PHP
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
[PHP] Re: mysql regexp select questions
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
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. ñ = ñ). 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ñ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
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: $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
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: $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: $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)
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 () $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] Re: Multilingual Web application - how to?
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] gettext - multi text domains ?
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
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] variable object creating
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] Server-Client connection via TCP port with PHP
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
Re: [PHP] Re: dynamic object instances
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: dynamic object instances
Jochem Maas wrote: Eli wrote: 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
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] Session creation time
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
[PHP] Running snippets from within PHP
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] Using API in other languages
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
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
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] Re: string lenght?
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 ?
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 ?
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
benifactor wrote: also i need to know how to find out how fast a page renders example; page rendered in 1.114 seconds -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getopt usage?
I can't seem to find any examples of code using getopt() around. I'm thinking not many people use php for command line shell scripts. Here is what i came up with for getopt(); The problem with this is it never hits default in the switch. If you give an argument that it doesn't know about it accepts it without doing anything and without an error, same thing if you don't give a value for an argument thats supposed to have one (like -a above). Oh and --long arguments would be nice too. So why not use the Console/Getopt.php library you ask. Because i can't figure out how to parse the output array. I can figure out the first part readPHPArgv(); array_shift($args); $shortoptions = "a:bc"; $longoptions = array("long", "alsolong=", "doublelong=="); $options = $optclass->getopt( $args, $shortoptions, $longoptions); print_r($options); ?> But that returns an array with more then one dimension and i have no idea how to loop though to set variables like i did with getopt(). My questions are what is the preferred way to get command line options, is there a way to give errors and take long arguments with getopt(), and how would one parse though the array returned from $optclass->getopt? Code examples of anyone using getopt(); or Getopt.php would be greatly appreciated. thanks eli PS anyone ever thought of setting up a website and maybe mailing list devoted to php as a shell scripting language (not web scripting) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Memory Size (4.1.2 vs 4.2.1)
Ok, thanks to everyone's help here, I just finished doing a minimalistic compile of PHP 4.2.1, (removing mysql, posix, session, and xml). However, I then replace my existing 4.1.2 with it (yeah, I was upgrading at the same time - If I had to recompile, might as well) And I was suprised, even after removing those parts, the memory req didn't seem to change much: Before: (stock compile of 4.1.2 plus GD) Apache process took 5.5Mb RAM, 1.8Mb resident After: (reduced compile of 4.2.1 plus GD) Apache process took 5.2Mb RAM, 2.0Mb resident So the overall size dropped, but the resident rose. And overall, not by that much? So is 4.2.1 that much bigger to cancel out the reduced compile? Or are removing those parts just so small that it doesn't make much of a difference? Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cache_limiter & cache_expire
Hello All, I would like to do that the session will expire after X minutes, and the page at the client will expire after Y minutes. How can I do that? I understand that session_cache_limiter() function determines who can cache the page: - pulic:proxies and clients. - private:clients. - nocache: no-one. But session_cache_expire() function sets expire on what? the session timeout or the page cache timeout? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cache_limiter & cache_expire
Hello All, I would like to do that the session will expire after X minutes, and the page at the client will expire after Y minutes. How can I do that? I understand that session_cache_limiter() function determines who can cache the page: - pulic:proxies and clients. - private:clients. - nocache: no-one. But session_cache_expire() function sets expire on what? the session timeout or the page cache timeout? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] picturing webpage
Hello All, I wanted to know if it is possible to picture a webpage via PHP. By "picturing" I mean that the program can generate a picture, a view, out of the page URL given. (Like sometimes you have in search engines, that you see the site URL and besides is the picture of the first page of the site). What technologies I use for that? Is it possible with PHP? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web page thumbs
I asked it before, and got a fine tool at this site: http://www.babysimon.co.uk/khtml2png/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Timeline for Apache 2 full use?
As the subject says, can anyone give me a timeline estimate for full usage (not experimental) of PHP within Apache 2.0? I ask because I am the maintainer of a server that recently got LOADS of hits, and was brought to it's knees (Hubble Space Telescope). We managed through, but during problem solving afterwards we have decided that Apache 2.0 with it's threads would have helped us greatly under our load. the problem is that we were just getting ready (in say a month) to go live with a very large PHP piece ... and if they can't work together ... well ... hrmmmm. Thanks, Eli Computer Specialist for Internet Services [EMAIL PROTECTED] http://hubblesite.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] Timeline for Apache 2 full use?
*cackle* Ok, and after I get fired for having to explain to my boss that it was my fault that the server was down because I was playing with experimental code, I'll have plenty of time to write you back about the problems I encountered :) Seriously though, if at this point, all the 'base code' of PHP is certified, could it be possible to start a checklist of which modules have been certified and which haven't? In the code we will be using, we are actually using surprisingly few libraries: Arrays, Date/Time, Directories, Filesystem, and Math ... If a list could be formed, of what was definitely safe, then perhaps some people, like us, could start using it earlier, knowing that we weren't doing other stuff (like image manipulation, DB access, etc.) Eli >The best way for PHP's Apache 2.0 module to escape from "experimental" >status is to have the confidence of sites like yours running the >code. Most of the showstopping bugs have been fixed. You can see a list >of the outstanding bugs on our bug tracking site: http://bugs.php.net/ > >I suggest you take PHP 4.2.1 with Apache 2.0.36 (running the worker >MPM) and run your workload on it. At this point the only uncertainty >with the code comes from the multithreaded nature of Apache 2 and how >that will interact with 3rd party libraries that may not be reentrant >or threadsafe (as Rasmus points out). > >If you encounter any bugs, please report them. More importantly, if >you have success please let us know. :) > >-aaron (one of the apache2filter maintainers) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] Timeline for Apache 2 full use?
At 01:00 PM 5/13/2002 -0700, Aaron Bannert wrote: >We would appreciate any feedback you could give, but if you are looking >for a committment on our part to some guarantee of code quality, I >suggest you review the license. No, I wasn't ... I just initially wanted to know if there was any planned timeline for work on it, since all lists I could find about what was being worked on, didn't include that, and at least personally, I felt that working with Apache 2 would have been a pretty high priority thing, and so figured that someone might have known ... :) That's all. And yes, I have a dev server where I try all my new software and play with stuff. And I will be playing with Apache2/PHP4 on it. But I can't transfer any of the current load to it, because to us, breaking for even one person, is a bad thing. We strive to provide the best possible experience for everyone, and knowingly breaking for someone, when we didn't have to, is 'bad'. (bad use of government money too, at least seen as such). So I can test on my spare server, load it myself as I see fit, but not send 'real people' there. Eli -- 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
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
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 : > 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 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
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 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 : >> 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 > 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
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 wrote: > On 12 April 2011 11:59, Eli Orr 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 : >>> 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 > 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 ... #@& As PHP will only actually parse the content between , the #@& string (the BOM) is simply sent straight through to the web server -> the client with no interruption. Now, if your code was ... #@& 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
RE: [PHP] $_POST vars
Hi Jim, Sure you can create set of et of $_POST vars : e.g. 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] Please help to unsubscribe
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
[PHP] Unix-Apache: running apache as different user
Hello All, I have PHP installed on Apache and Unix with several vhosts so each vhost has its own user account on Unix. Now when accessing a webpage, Apache runs with user httpd.. but I want it to run as the user of the vhost account.. How can I do that? thanks in advnce, -Lorderon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Improve server HTTP GET server response - HTTP 1.1 ?
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=MIRS&ID=23412341234&OS=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 ?
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=MIRS&ID=23412341234&OS=RIM <http://mimmage.com/cms/client_initialize1.php?OPERATOR=MIRS&ID=23412341234&OS=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_
[PHP] How to DUMP $_POST parameters to a log file? Very useful and missing in the php.net
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_