Re: [PHP] Ini files for CLI only on non Win32 platform
On 13 September 2013 20:06, Kevin Kinsey k...@daleco.biz wrote: Date: Fri, 13 Sep 2013 11:40:27 +0100 From: Richard Quadling rquadl...@gmail.com To: PHP General list php-general@lists.php.net Subject: [PHP] Ini files for CLI only on non Win32 platform. I've got an instance of PHP that is looking for additional ini files in /etc/php.d This seems to work well. I now need to make one of the ini files only accessible if the SAPI is CGI. So, I renamed the file ... mv /etc/php.d/my.ini /etc/php.d/my-cgi.ini If I do a ... php --ini I still see the ini file. Is the -SAPI filtering performed on the additional files? It doesn't seem to and I can't really tell from the dox if it is supposed to. Shouldn't the file name be php-cgi.ini ? Manual: If php-SAPI.ini exists (where SAPI is the SAPI in use, so, for example, php-cli.ini or php-apache.ini), it is used instead of php.ini. The SAPI name can be determined with php_sapi_name(). I'm in CLI mode here; note that my-cli.ini is ignored but php-cli.ini is not: [1016] Fri 13.Sep.2013 13:52:05 [kadmin@freebsd-devel][/www/data/] php --ini Configuration File (php.ini) Path: /usr/local/etc Loaded Configuration File: /usr/local/etc/php.ini Scan for additional .ini files in: /usr/local/etc/php Additional .ini files parsed: /usr/local/etc/php/extensions.ini [1017] Fri 13.Sep.2013 13:52:08 [kadmin@freebsd-devel][/www/data/] sudo touch /usr/local/etc/php-cgi.ini [1018] Fri 13.Sep.2013 13:52:26 [kadmin@freebsd-devel][/www/data/] sudo touch /usr/local/etc/php-cli.ini [1019] Fri 13.Sep.2013 13:52:32 [kadmin@freebsd-devel][/www/data/] sudo touch /usr/local/etc/my-cli.ini [1020] Fri 13.Sep.2013 13:52:44 [kadmin@freebsd-devel][/www/data/] php --ini Configuration File (php.ini) Path: /usr/local/etc Loaded Configuration File: /usr/local/etc/php-cli.ini Scan for additional .ini files in: /usr/local/etc/php Additional .ini files parsed: /usr/local/etc/php/extensions.ini I apologize if I'm missing the point or am obtuse or irrelevant; I don't play with the INI files very often. Kevin Kinsey Ah! Yes. The main ini file can be php-sapi.ini and the code is going to look for the sapi specific file before the non specific file. If you are also using an additional path (as the setup I'm working on does), then ALL files in that path are included. I just took a look at the source (and not sure why I didn't before) at https://github.com/php/php-src/blob/master/main/php_ini.c#L565 and that code deals with the sapi specific names. After that, the additional path is scanned and all .ini files included. No filtering by SAPI. Using PHPRC environment variable sets a single ini file. Using PHP_INI_SCAN_DIR environment variable overrides/sets the scanned directory. Just looking into adding a [SAPI] section for INI files (matching the behaviour of [HOST] and [PATH]. -- Richard Quadling Twitter : @RQuadling
[PHP] Ini files for CLI only on non Win32 platform.
Hi. I've got an instance of PHP that is looking for additional ini files in /etc/php.d This seems to work well. I now need to make one of the ini files only accessible if the SAPI is CGI. So, I renamed the file ... mv /etc/php.d/my.ini /etc/php.d/my-cgi.ini If I do a ... php --ini I still see the ini file. Is the -SAPI filtering performed on the additional files? It doesn't seem to and I can't really tell from the dox if it is supposed to. Regards, Richard. -- Richard Quadling
Re: [PHP] Ambiguous?
On 09/08/2013 14:00, Karl-Arne Gjersøyen wrote: 1) query foreach($varenr_inn_pa_lager as $vnr){ include('../../tilkobling.php'); $sql = SELECT * FROM exan,dynamit WHERE varenr = '$vnr' LIMIT 1; $resultat = mysql_query($sql, $tilkobling) or die(mysql_error()); 2) Result: Column 'varenr' in where clause is ambiguous 3) Tables in MySQL database mysql SELECT * FROM exan; ++-+---+--+--+-+ | leverandor | valgt_lager | un_nr | varenavn | varenr | kg_pa_lager | ++-+---+--+--+-+ mysql SELECT * FROM dynamit; ++-+---++---+-++-+ | leverandor | valgt_lager | type | dim_mm | un_nr | varenavn| varenr | kg_pa_lager | ++-+---++---+-++-+ 4) My question: What means with ambiguous here? Thanks. Karl a field named 'varenr' exists in both tables - your sql query needs to specify from which table you are selecting the data. foreach($varenr_inn_pa_lager as $vnr){ include('../../tilkobling.php'); $sql = SELECT * FROM exan,dynamit WHERE varenr = '$vnr' LIMIT do you really need to include the file 'tilkobling.php' repeatedly for each iteration over $varenr_inn_pa_lager?? Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Stripe Connect in the UK + PHP Integration.
On 19 July 2013 16:22, Richard Quadling rquadl...@gmail.com wrote: Hi. Simple question. Has anyone got Stripe Connect, Stripe.js and Stripe PHP SDK operational in the UK. I'm struggling getting the UK Beta to accept a new account/customer set for a UK business or individual, accepting GBP. And I'm in the UK Beta! Any help would be appreciated. Off list if preferred. Regards, Richard Quadling. Just in case anyone comes back with this, I've got it sorted. The UK Beta is by invite only. So to get our merchants signed up, we had to email them an invite. They then register, authenticate and then authorise our app with their account. Very long winded and unnecessary. Fortunately, Stripe fixed it for us (well, others too probably). Now the signup is via our app (just like GoCardless) and all working well. So. Stripe UK is on it's way. Hopefully! Just seen the price of stripe.co.uk ... £22,000! Ha! -- Richard Quadling Twitter : @RQuadling
[PHP] Quick Q.
PHP 5.5+ is (from news) - Windows XP and 2003 support dropped. Does that mean no longer executes (as is seemingly what I'm seeing) or just no longer supported/developed? Just going to look into getting to the bottom of the CHM build issues and only have an XP license of Windows. Will drop back to PHP 5.4 to see if that's OK on the VM I have. -- Richard Quadling
Re: [PHP] COM - Assigning to method.
On 15 July 2013 16:27, Andrew Ballard aball...@gmail.com wrote: On Mon, Jul 15, 2013 at 4:21 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Andrew Thanks for this. But I'm still getting errors. I think I need to explain a bit more. Unfortunately there isn't a PHP API for this application I'm trying to interact with, my goal really is to be able to expose the COM functionality over a web-service such as SOAP so I can use it in a CMS. The application I'm trying to integrate with is Blackbuad's Raiser's Edge - API documentation here: https://www.blackbaud.com/files/support/guides/re7ent/api.pdf I think part of the problem is that the field names are also represented by an integer. So to get data out I would do: $oBank-Fields(22); // which maps to BANK_fld_BRANCH_NAME. When I do: $oBank-22 = 'blah blah'; I get an error because a property can't be numeric, it has to start as alpha character. If I use: $oBank-BANK_fld_BRANCH_NAME = 'blah blah blah'; I get the following error: Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `BANK_fld_BRANCH_NAME': Unknown name. I've also tried using your Value property returned by Fields(): $oBank-Fields(22)-Value = 'Blah Blah blah blah'; Which I then get: PHP Warning: Creating default object from empty value in [C:\Users] Fatal error: Call to undefined method variant::Save() Soo seems nearly impossible to implement a safe way to write to the COM API. At the moment, I'm still in the scoping/prototype stage of my project, so I'm beginning to think that using this COM API for this project is a no-go, which is unfortunate. I'm also guessing even if we did implement this API, exposing it as a Web Service is going to be tricky for performance sake (given that I've read that COM doesn't multithread very well??) Many Thanks Adam. It's definitely possible to do, once you figure out the syntax you need for this object. I'm guessing you must have gotten past the $oBank-Init() method call without issues. What happens if you just use this for the value assignment? $oBank-Fields(BANK_fld_ACCOUNT_NAME) = Test account; $oBank-Fields(BANK_fld_ACCOUNT_NO) = 12345; $oBank-Fields(BANK_fld_BANK) = Bank of the Nation; $oBank-Fields(BANK_fld_BRANCH_NAME) = State Street Branch; It also looks like you're getting errors from the call to $oBank-Save() saying that the method is not defined. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I used to use PHP+Windows+COM+Crystal Reports. I'm in the middle of something else, but a few things. Does the library you are using have a valid COM interface? Some of the .NET libraries simply don't. The last version of CR that was COM enabled was CR XI R 2. After that it was .NET and Java only. No COM. Having said that, I never got around to using http://uk1.php.net/manual/en/class.dotnet.php, so I don't know how this all worked. From memory the DOTNET layer of PHP was just a wrapper around COM and still required COM exposure in the lib. I think. Use a TypeLib Explorer to see exactly what interface is available - from memory, the right tool is all you need. I was able to code anything I needed with Crystal Reports. There is also a PHP function http://uk1.php.net/manual/en/function.com-load-typelib.php which I used to allow the various constants within the typelib to be exposed and usable within PHP. And also look at http://uk1.php.net/manual/en/function.com-print-typeinfo.php and the user notes. Not used it but bucket loads of info is a good thing to see normally. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] Quick Q.
On 24 July 2013 21:54, Matijn Woudt tijn...@gmail.com wrote: On Wed, Jul 24, 2013 at 10:45 PM, Richard Quadling rquadl...@gmail.comwrote: PHP 5.5+ is (from news) - Windows XP and 2003 support dropped. Does that mean no longer executes (as is seemingly what I'm seeing) or just no longer supported/developed? Just going to look into getting to the bottom of the CHM build issues and only have an XP license of Windows. Will drop back to PHP 5.4 to see if that's OK on the VM I have. Hi, It is only no longer supported/developed. It probably will compile fine on it for a long time, though some new features might not. It probably also means they are not going to test on XP/2003 anymore, and will not respond to bugs related to these operating systems. - Matijn From what I can see, PHP V5.5.1 (just downloaded onto a clean VM) fails to execute. But V5.4.17 works fine. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] How to extract php source code from joomla
On 23/07/2013 16:54, Yoinier Hernandez Nieves wrote: El 22/07/13 15:49, elk dolk escribió: Thank you for the quick response ! What I am trying to do : I have to complete two university projects for my professor ! project One : Make an online shop and must use the following components in it Shopping cart, Catalog of products, payment gateway , user login and user activity log . You can use Prestashop, Magento, Oscommerce, etc, and modify at you're needed. IMO do NOT use Oscommerce (or the ZenCart fork for that matter) ... unless you want a lesson in how not to write an application in PHP... the code and architecture is (well it was the last time I had the dubious pleasure of working with it...) truly awful Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Stripe Connect in the UK + PHP Integration.
Hi. Simple question. Has anyone got Stripe Connect, Stripe.js and Stripe PHP SDK operational in the UK. I'm struggling getting the UK Beta to accept a new account/customer set for a UK business or individual, accepting GBP. And I'm in the UK Beta! Any help would be appreciated. Off list if preferred. Regards, Richard Quadling.
Re: [PHP] COM - Assigning to method.
On 13 July 2013 01:24, Andrew Ballard aball...@gmail.com wrote: On Jul 12, 2013 4:53 AM, Adam Nicholls inkysp...@gmail.com wrote: Hi Guys/Gals, I'm doing some integration work with a COM API and according to their documentation to save data in the API, you have to assign to the method. This is their example in Visual Basic: - Set oBank = New CBank oBank.Init Application.SessionContext With oBank .Fields(BANK_fld_ACCOUNT_NAME) = Test account .Fields(BANK_fld_ACCOUNT_NO) = 12345 .Fields(BANK_fld_BANK) = Bank of the Nation .Fields(BANK_fld_BRANCH_NAME) = State Street Branch End With oBank.Save - Obviously in PHP is isn't possible to assign to a method in this way (thats what parameters are for!) So I'm at a bit of a loose end. I'm wondering if anyone else has come across this? Or am I missing something obvious in PHP's implementation of the COM that allows me to work around this? My PHP Code is looks like this: - $API = new COM('API7.API'); $API-Init($SerialNo, $Login, '', 1, '', 1); $API-SignOutOnTerminate = True; $Record = new COM(Data.Record); $Record-Init($API-SessionContext); $Record-Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work - I've also tried (below) but the API says wrong number of parameters $Record-Fields('BANK_fld_ACCOUNT_NAME', 'Test Account'); I've also tried something crazy like this (below) but that overwrites the $Record object. $_R = $Record-Fields('BANK_fld_ACCOUNT_NAME'); $_R = 'Test Account'; Any ideas? Is it possible? Many Thanks Adam Nicholls That example isn't assigning values to method return value. Fields is a collection of ADO Field objects. The default property of a Field object is its Value property, so the shorthand is simply assigning the values of the variables to the value of each field in a record within a Recordset. Andrew So .. $oBank-BANK_fld_ACCOUNT_NAME = Test account; sort of thing. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] Guaranteed Way to Get Error Message Wanted
On 6 July 2013 19:50, Brian Smither bhsmit...@gmail.com wrote: It looks like you are running the thread-safe version with FastCGI, which I understand to be counter to the recommendations. Thank you for the comment. I switched to PHP5.4.17-NTS-VC9, but the application still crashes. And still no clue as to why. So, still looking for that magic method to get PHP to report what's happening on a 500 Internal Server Error when it's (presumably? not sure...) not the server's fault. Have you got all your extensions updated? Enable display_startup_errors. Try running the command line PHP ... php -r echo 1; With your config. Just to see if there is anything ultra obvious missing. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] Guaranteed Way to Get Error Message Wanted
On 6 July 2013 21:45, Brian Smither bhsmit...@gmail.com wrote: Have you got all your extensions updated? I would think so. Just to state the required disclaimers: phpinfo.php with ? phpinfo() ? works. Liberally peppering a tracer routine throughout the application shows it is getting executed up until one spot. But there is nothing obviously wrong with the code. Nothing! That's why I need the guaranteed message delivery on why PHP does not like the code. Turn on all your error reporting/logging. Add a try/catch if appropriate. Turn off any unhandled exception processing. Load in XDebug and get a trace going, what is the code doing prior to failure? -- Richard Quadling Twitter : @RQuadling
[PHP] Web dev, DB and proper db design.
Hi. I've just had a conversation regarding DB, foreign keys and their benefits. I was told I've never worked on a web application where foreign keys were used in the database. As someone who has spent 25 years working on accounting/epos systems on MS SQL Server (yep, windows) and now in a web environment and hearing the above, ... well, ... slightly concerned. So, in the biggest broadest terms, what do you lot do? DBs with no foreign keys (constrainted or not). ORM builders with manual definition of relationships between the tables. Inline SQL where you have to just remember all the relationships. Views for simple lookups? How do you handle updatable views (does mysql support them?) etc. Is there a difference in those in 'startups' and web only situations, or those doing more traditional development (split that as you like - I'm just trying to get an understanding and not go off on one!). No definitive answers, and I hope I get some wide experiences here. Thanks for looking. Richard.
Re: [PHP] What is the name of the pattern that will ...
On 13 June 2013 18:38, David Harkness davi...@highgearmedia.com wrote: Hi Richard, On Thu, Jun 13, 2013 at 10:16 AM, Richard Quadling rquadl...@gmail.comwrote: I'm building a class which needs to have certain methods called by the subclass, but the subclass can extend but not obscure/override the behaviour. This is the Template Method pattern, though in this case you could use a Strategy where the specific authentication implementation is in a separate class that gets injected into the Auth class. As for your example there a a few things I would change. * The template method that the subclass must implement should not be declared by an interface. Interfaces are for declaring public contracts. You can simply declare an abstract, protected method in Auth. This is the contract that every subclass must fulfill. * I would avoid reference variables as you've indicated. If you don't want to build a data-holder class yet, simply return an array for now. While you cannot enforce the return type at parse time, they should be verified with unit tests. Unit tests are critical with dynamic languages like PHP and Python since runtime is the only way to verify behavior. Otherwise, your example is spot on, though the name AuthRequestMade implies the request has already been made yet I think from your description that this method should *make* the actual request. Here's how I would write it with the above in place. class Auth { public function MakeAuthRequest() { // before $this-MakeAuthRequestImpl(); // Adding Impl suffix is a common convention // after } /** * Make the actual authentication request. * * @return array Must contain keys state and message to hold the result */ protected abstract function MakeAuthRequestImpl(); } Peace, David Excellent advice. I will be making an extendable data holder class. I'm going to do the sort of thing Zend_Db does for the adapter/rowset/row classes, allowing an extended class to supply the corresponding extended adapter/rowset/row classes. Each of the base classes has a job to do, but they can only operate in conjunction with an external provider. Thanks for the pointers. Richard. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: AW: [PHP] PHP is Zero
On 13/06/2013 11:44, BUSCHKE Daniel wrote: Hi, thanks for your answer. Especially the answer 42 made me laughing :) My Why questions should be understand as Why must it be like that questions. On 13/06/13 08:59, BUSCHKE Daniel wrote: 5. Thats a bug I have opend: https://bugs.php.net/bug.php?id=51739 where I also had the same problems because 8315e839da08e2a7afe6dd12ec58245d was converted into float(INF) by throwing everything starting from da08.. away. That's a very different proposition, and probably has more to do with word size: float is 32-bit, so only the first 32 bits are used and if anything else is found the conversion falls back to INF. To handle really big integers like 8315e839da08e2a7afe6dd12ec58245d you probably need a more specialist library (or language) For me it is not. PHP throws things away during conversion. In my opinion a language (compiler, interpreter whatever) should not do that. Never ever! Either it is able to convert the value or it is not. What about of returning null instead of 0 if the conversion is not perfect? So intval('F') could return NULL and intval('0') could return 0. Regards Daniel I think you will have to live with this or use another language for development - IMO it will never change because of the massive BC break that would be produced by changing the type juggling behaviour... of course you could always post an RFC to the dev/internals list if you want to take this further... good luck with that! Cheers Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What is the name of the pattern that will ...
Hi. I'm building a class which needs to have certain methods called by the subclass, but the subclass can extend but not obscure/override the behaviour. So, for example, a method AuthRequestMade() will record the activity of making an authorisation request. It cannot make the actual request as that is the subclass's job, but, no matter what, I need to have this method called with the result of the actual auth request. I want to make building the subclasses as simple and as fool proof as possible. I think I have to do something like this ... interface AuthEnforcer{ public function AuthRequestMade($i_State, $s_Message); } abstract class Auth implements AuthEnforcer{ public method MakeAuthRequest(){ // Do my stuff before. // Call the SpecificAuth class $this-AuthRequestMade($i_State, $s_Message); // Do my stuff after with state and message. } } class SpecificAuth extends Auth{ public function AuthRequestMade($i_State, $s_Message){ // Do my specific stuff, setting state and message. } } But a couple of things I don't like (and don't know how to avoid). 1 - The SpecificAuth::AuthRequestMade is public and I want it protected as it shouldn't be called from the public scope. 2 - The response is by ref, but I think having a AuthResponse class containing $i_State and $s_Message should be enough there, but no way to enforce return types in PHP. Any ideas? Thank you. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] Seemingly incorrect strict standard.
On 3 June 2013 20:37, shiplu shiplu@gmail.com wrote: Show a short reproducible code. Short-ish ... ?php abstract class baseClass { static public function generateLocalisedContent($s_Stuff){ throw new Exception('Must implement static public function ' . get_called_class() . '::generateLocalisedContent().'); } public function __construct($s_Stuff){ echo static::generateLocalisedContent($s_Stuff); } } class sub1 extends baseClass{} class sub2 extends baseClass{ static public function generateLocalisedContent($s_Stuff){ return 'Your stuff is ' . $s_Stuff . PHP_EOL; } } try { $o1 = new sub1('Stuffed1'); } catch(Exception $ex){ echo $ex-getMessage(), PHP_EOL; } try { $o2 = new sub2('Stuffed2'); } catch(Exception $ex){ echo $ex-getMessage(), PHP_EOL; } ? And I can now see an interface is a much simpler mechanism! -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] Seemingly incorrect strict standard.
On 4 June 2013 09:57, Richard Quadling rquadl...@gmail.com wrote: On 3 June 2013 20:37, shiplu shiplu@gmail.com wrote: Show a short reproducible code. And I can now see an interface is a much simpler mechanism! ?php interface baseInterface { static public function generateLocalisedContent($s_Stuff); } abstract class baseClass implements baseInterface { public function __construct($s_Stuff) { echo static::generateLocalisedContent($s_Stuff); } } class sub1 extends baseClass{} class sub2 extends baseClass{ static public function generateLocalisedContent($s_Stuff){ return 'Your stuff is ' . $s_Stuff . PHP_EOL; } } try { $o1 = new sub1('Stuffed1'); } catch(Exception $ex){ echo $ex-getMessage(), PHP_EOL; } try { $o2 = new sub2('Stuffed2'); } catch(Exception $ex){ echo $ex-getMessage(), PHP_EOL; } ? PHP Fatal error: Class sub1 contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (baseInterface::generateLocalisedContent) in - on line 12 A much more meaningful error. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] Seemingly incorrect strict standard.
Aha! Don't make it abstract in my base class, but I can throw an exception (perfectly reasonable for me as the called class should implement the method). On 3 June 2013 18:36, Matijn Woudt tijn...@gmail.com wrote: On Mon, Jun 3, 2013 at 7:24 PM, Richard Quadling rquadl...@gmail.comwrote: Hi. I've got an abstract class which requires one of the concrete descendants to implement a static function. The base class will call it using static:: rather than self::. But I'm getting an error at runtime. Static function should not be abstract. It doesn't SEEM right to inhibit this. Am I missing something? I'm on PHP 5.4.15 (Mac and Centos). Hi Richard, This change is done on purpose. From the PHP manual: Dropped abstract static class functions. Due to an oversight, PHP 5.0.x and 5.1.x allowed abstract static functions in classes. As of PHP 5.2.x, only interfaces can have them. I believe you could make yourself in trouble when using it, and that's why there is a warning with strict. It does make sense, because overloading is something that works on classes, and static functions do not reference classes. - Matijn -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] Simple objective which always seems to make me think I'm doing it wrong.
On 23 May 2013 16:31, Stuart Dallas stu...@3ft9.com wrote: On 23 May 2013, at 15:54, Richard Quadling rquadl...@gmail.com wrote: I'm building an XML file. It is within an OOP structure and is pretty simple. The method is ... /** * Turn an error from the W2GlobalData service into normal document as this will make it easier to integrate downstream. * * @param \SimpleXMLElement $o_XML * @return \SimpleXMLElement * @todo Build document to be a correct request header with the embedded error message. */ public function normaliseError($o_XML) { $s_XML = END_XML ?xml version=1.0 encoding=UTF-8? doc serviceUK Verification (Edited)/service searchtext forename{$this-a_RequestData['forename']}/forename middlename{$this-a_RequestData['middlename']}/middlename surname{$this-a_RequestData['surname']}/surname address1{$this-a_RequestData['address1']}/address1 address2{$this-a_RequestData['address2']}/address2 postcode{$this-a_RequestData['postcode']}/postcode gender{$this-a_RequestData['gender']}/gender dob{$this-a_RequestData['dob']}/dob drivinglicence{$this-a_RequestData['drivinglicence']}/drivinglicence passport{$this-a_RequestData['passport']}/passport mpan{$this-a_RequestData['mpan']}/mpan /searchtext clientreference{$this-a_RequestData['clientreference']}/clientreference resultcount/ searchdate/ expiry/ timetaken/ reportemailsent/ error {$o_XML-error} /error /doc END_XML; return new SimpleXMLElement($s_XML); } Nothing particularly difficult to understand, but I just don't like having the XML embedded this way. Ideally, I want a scope aware include function, so I can say _something_ like ... $s_XML = require_once __CLASS__ . DIRECTORY_SEPARATOR . 'normalisedError.xml'; and have the include be aware of the local scope (so $o_XML and $this are all happy). I know I can write a template parser, but I'm just missing an obvious solution that isn't fat and doesn't require a massive learning for the other devs. Ideas? normalisedError.xml: ?php return END_XML the xml here END_XML; Then in your class your require_once line will work. However, use require instead of require_once otherwise if the function gets called twice it won't work the second time. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ Perfect!!! Thanks -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
[PHP] Simple objective which always seems to make me think I'm doing it wrong.
Hi. I'm building an XML file. It is within an OOP structure and is pretty simple. The method is ... /** * Turn an error from the W2GlobalData service into normal document as this will make it easier to integrate downstream. * * @param \SimpleXMLElement $o_XML * @return \SimpleXMLElement * @todo Build document to be a correct request header with the embedded error message. */ public function normaliseError($o_XML) { $s_XML = END_XML ?xml version=1.0 encoding=UTF-8? doc serviceUK Verification (Edited)/service searchtext forename{$this-a_RequestData['forename']}/forename middlename{$this-a_RequestData['middlename']}/middlename surname{$this-a_RequestData['surname']}/surname address1{$this-a_RequestData['address1']}/address1 address2{$this-a_RequestData['address2']}/address2 postcode{$this-a_RequestData['postcode']}/postcode gender{$this-a_RequestData['gender']}/gender dob{$this-a_RequestData['dob']}/dob drivinglicence{$this-a_RequestData['drivinglicence']}/drivinglicence passport{$this-a_RequestData['passport']}/passport mpan{$this-a_RequestData['mpan']}/mpan /searchtext clientreference{$this-a_RequestData['clientreference']}/clientreference resultcount/ searchdate/ expiry/ timetaken/ reportemailsent/ error {$o_XML-error} /error /doc END_XML; return new SimpleXMLElement($s_XML); } Nothing particularly difficult to understand, but I just don't like having the XML embedded this way. Ideally, I want a scope aware include function, so I can say _something_ like ... $s_XML = require_once __CLASS__ . DIRECTORY_SEPARATOR . 'normalisedError.xml'; and have the include be aware of the local scope (so $o_XML and $this are all happy). I know I can write a template parser, but I'm just missing an obvious solution that isn't fat and doesn't require a massive learning for the other devs. Ideas? Thanks for reading. Richard. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
[PHP] Trying to understand what I've broken to not allow mkdir() to work.
Hi. I'm running on a Mac with a Centos VM (via VirtualBox). Was running from from our SVN server. New repo, now running from GIT. The checkout is on my local machine (using Netbeans, LESS, etc.) The VM is running Apache and PHP V5.4.15 During the move, I've got some permissions issues, which I simply don't understand enough to a) resolve myself, b) know what to ask for to get the right help in solving the issue. I've been told that the permissions on my mac via the shared folder through VirtualBox to the Centos setup is where my problem lies. But I don't know. Is there anyone who can give me definite help here? I can manually create the directories, but that's just daft. Nothing LOOKS any different between the two repos, but I don't know how to tell beyond comparing ls outputs. Any help would be good. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] Trying to understand what I've broken to not allow mkdir() to work.
On 16 May 2013 15:42, Karim Geiger gei...@b1-systems.de wrote: Hi Richard, On 05/16/2013 04:33 PM, Richard Quadling wrote: Hi. I'm running on a Mac with a Centos VM (via VirtualBox). Was running from from our SVN server. New repo, now running from GIT. The checkout is on my local machine (using Netbeans, LESS, etc.) The VM is running Apache and PHP V5.4.15 During the move, I've got some permissions issues, which I simply don't understand enough to a) resolve myself, b) know what to ask for to get the right help in solving the issue. I've been told that the permissions on my mac via the shared folder through VirtualBox to the Centos setup is where my problem lies. But I don't know. Is there anyone who can give me definite help here? I can manually create the directories, but that's just daft. Nothing LOOKS any different between the two repos, but I don't know how to tell beyond comparing ls outputs. Any help would be good. What happens if you're making an ls -la in your Terminal on your SVN folder? Could you paste the output? It looks like the owner or permissions of the folder aren't correct. Regards Karim -- Karim Geiger Auszubildender Fachinformatiker AE B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 Seems the mounting is the issue. mount -o nosuid,uid=apache,gid=apache -t vboxsf ccdev /mnt/newbuild And that has mounted the drive and the mkdir() is working! And in further looking, my /etc/fstab was trying to mount ccdev to /mnt/trunk ... ARGH!!! Sorry for the noise. I need a beer now! -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] Having a problem with clone.
On 11 May 2013 09:52, Marco Behnke ma...@behnke.biz wrote: Am 10.05.13 11:35, schrieb Richard Quadling: Trying to clone an uncloneable object of class Smarty_Variable Different PHP versions maybe? Look at this thread I found: http://wordpress.org/support/topic/fatal-error-trying-to-clone-an-uncloneable-object-of-class-reflectionclass The last post Not applicable. That option was deprecated and removed in 5.3. The issue is in the Gender extension. Looking at the recent patch to trunk it looks potentially OK. Not an expert there. Will be able to test this on Monday. Thanks though. Regards, Richard. -- Richard Quadling Twitter : @RQuadling
[PHP] Having a problem with clone.
Hi. I'm having an issue where I get ... Fatal error: Trying to clone an uncloneable object of class Smarty_Variable in xx/trunk.newbuild/includes/frontend/site_includes/classes/smarty-3.10/sysplugins/smarty_internal_template.php on line 269 This issue happens consistently on our live server and on our test server, but not on my dev setup. The issue doesn't happen if I comment out 1 line of completely unrelated code ... $o_Gender = new Gender\Gender; If I immediately follow that with ... unset($o_Gender); and have no other access to $o_Gender, I still get the error. Comment out the code, no problems. The extension is used in other parts of the system with seemingly no problem. That is, the code behaves as expected and I get no errors, but those elements don't use Smarty. The error being reported is clearly wrong. And the extension (as far as I can see) has no interaction with global elements in any way (I have to use the Gender namespace to access anything in it - which I think is correct). I've var_dump()'d a debug_backtrace() at the point of failure in the Smarty code, with and without the $o_Gender variable being defined (it isn't used in the Smarty template - so Smarty is never touching it). When I compare the 2 dumps, the only differences is in the datetime stamp elements and the object count values (there's 1 more when $o_Gender exists). My setup is on a CentOS VM running PHP V5.4.14 The live setup is on a remote CentOS server running PHP V5.3.21 The test server is on CentOS server running PHP V5.3.3 I don't know CentOS well enough to just swap out a new version of PHP. But I will be getting some help on that. Where do I start to find the problem? I have full root access to the command line test server, so I can, within reason, follow instructions to run/wrap the code in any way needed. Any help would be GREATLY appreciated!!! Thanks in advance, Richard. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] Having a problem with clone.
On 10 May 2013 12:08, Nick Whiting nwhit...@xstudiosinc.com wrote: Do you have a backtace for this? What is the gender class doing? Have u done a global search for keyword clone? On Friday, May 10, 2013, Richard Quadling wrote: Hi. I'm having an issue where I get ... Fatal error: Trying to clone an uncloneable object of class Smarty_Variable in xx/trunk.newbuild/includes/frontend/site_includes/classes/smarty-3.10/sysplugins/smarty_internal_template.php on line 269 This issue happens consistently on our live server and on our test server, but not on my dev setup. The issue doesn't happen if I comment out 1 line of completely unrelated code ... $o_Gender = new Gender\Gender; If I immediately follow that with ... unset($o_Gender); and have no other access to $o_Gender, I still get the error. Comment out the code, no problems. The extension is used in other parts of the system with seemingly no problem. That is, the code behaves as expected and I get no errors, but those elements don't use Smarty. The error being reported is clearly wrong. And the extension (as far as I can see) has no interaction with global elements in any way (I have to use the Gender namespace to access anything in it - which I think is correct). I've var_dump()'d a debug_backtrace() at the point of failure in the Smarty code, with and without the $o_Gender variable being defined (it isn't used in the Smarty template - so Smarty is never touching it). When I compare the 2 dumps, the only differences is in the datetime stamp elements and the object count values (there's 1 more when $o_Gender exists). My setup is on a CentOS VM running PHP V5.4.14 The live setup is on a remote CentOS server running PHP V5.3.21 The test server is on CentOS server running PHP V5.3.3 I don't know CentOS well enough to just swap out a new version of PHP. But I will be getting some help on that. Where do I start to find the problem? I have full root access to the command line test server, so I can, within reason, follow instructions to run/wrap the code in any way needed. Any help would be GREATLY appreciated!!! Thanks in advance, Richard. -- Richard Quadling Twitter : @RQuadling -- Nickolas Whiting Lead Developer X Studios 321-281-1708x107 The Gender class is from the pecl/Gender extension. As for a backtrace, the code is in Smarty and works fine if I don't have pecl/Gender instantiated. I'm guessing this is really an internals issue. The code operates on V5.3 and V5.4 without the extension with no issue. Put the extension in and only on one page (so far) do we get the issue. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] Having a problem with clone.
On 10 May 2013 12:18, Richard Quadling rquadl...@gmail.com wrote: On 10 May 2013 12:08, Nick Whiting nwhit...@xstudiosinc.com wrote: Do you have a backtace for this? What is the gender class doing? Have u done a global search for keyword clone? On Friday, May 10, 2013, Richard Quadling wrote: Hi. I'm having an issue where I get ... Fatal error: Trying to clone an uncloneable object of class Smarty_Variable in xx/trunk.newbuild/includes/frontend/site_includes/classes/smarty-3.10/sysplugins/smarty_internal_template.php on line 269 This issue happens consistently on our live server and on our test server, but not on my dev setup. The issue doesn't happen if I comment out 1 line of completely unrelated code ... $o_Gender = new Gender\Gender; If I immediately follow that with ... unset($o_Gender); and have no other access to $o_Gender, I still get the error. Comment out the code, no problems. The extension is used in other parts of the system with seemingly no problem. That is, the code behaves as expected and I get no errors, but those elements don't use Smarty. The error being reported is clearly wrong. And the extension (as far as I can see) has no interaction with global elements in any way (I have to use the Gender namespace to access anything in it - which I think is correct). I've var_dump()'d a debug_backtrace() at the point of failure in the Smarty code, with and without the $o_Gender variable being defined (it isn't used in the Smarty template - so Smarty is never touching it). When I compare the 2 dumps, the only differences is in the datetime stamp elements and the object count values (there's 1 more when $o_Gender exists). My setup is on a CentOS VM running PHP V5.4.14 The live setup is on a remote CentOS server running PHP V5.3.21 The test server is on CentOS server running PHP V5.3.3 I don't know CentOS well enough to just swap out a new version of PHP. But I will be getting some help on that. Where do I start to find the problem? I have full root access to the command line test server, so I can, within reason, follow instructions to run/wrap the code in any way needed. Any help would be GREATLY appreciated!!! Thanks in advance, Richard. The Gender class is from the pecl/Gender extension. As for a backtrace, the code is in Smarty and works fine if I don't have pecl/Gender instantiated. I'm guessing this is really an internals issue. The code operates on V5.3 and V5.4 without the extension with no issue. Put the extension in and only on one page (so far) do we get the issue. The clone error is incorrect as the object can be cloned, and is, very successfully, just not when I've created an instance of gender. I'm thinking there's a memory issue, but I don't know how to diagnose it. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
[PHP] pecl/gender bug in PHP V5.3
Hello all. Very odd behaviour. ?php if (extension_loaded('gender')) { $o_Gender = new Gender\Gender; var_dump($o_Gender); } class Variable { public $value = null; } $a = new Variable; $b = clone $a; var_dump($a, $b); ? If using pecl/Gender V0.9.0 with PHP V5.3.3, V5.3.13, V5.3.23, then I get an error ... PHP Fatal error: Trying to clone an uncloneable object of class Variable in - on line 14 No problem with V5.4.14 No idea why this is the case. Changelog for V5.3 doesn't reveal anything regarding cloning. I'm running this on a CentOS vm (not my speciality, so I can't diagnose any further, sorry). If anyone can shed some light on this, then that would be useful. Regards, Richard. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] [ask] convert unknown Korean's string to readable string
On 30 April 2013 18:56, Morning Star morning.star.c...@gmail.com wrote: Hi Richard, i am sure my KDE konsole is set to UTF-8. fortunately, i got a answer from the Debian mailing list. someone told me to verify if i had installed the ttf-baekmuk (Korean's font) or not. i see that it is not install yet. i just installed it and then i am able to view the Korean's font. Thanks anyway. Best regards, Marco On Tue, Apr 30, 2013 at 2:40 PM, Richard Quadling rquadl...@gmail.com wrote: On 29 April 2013 20:38, Morning Star morning.star.c...@gmail.com wrote: Thanks, Richard. It works in xterm, but it doesn't work in KDE konsole. i don't know how to figure it out. help me Best regards, Marco On Mon, Apr 22, 2013 at 9:43 AM, Richard Quadling rquadl...@gmail.com wrote: On 18 April 2013 08:06, Morning Star morning.star.c...@gmail.com wrote: $string = \uc548\ub155\ud558\uc138\uc694 ?php $string1 = '\uc548\ub155\ud558\uc138\uc694'; $string2 = preg_replace('/\\\u([0-9a-f]+)/', '#x$1;', $string1); $string3 = html_entity_decode($string2, ENT_COMPAT, 'UTF-8'); echo 'Original : ', $string1, PHP_EOL, 'Entities : ', $string2, PHP_EOL, 'Decoded : ', $string3, PHP_EOL, PHP_EOL; ? outputs (at least for me) ... 안녕하세요 Based upon http://stackoverflow.com/questions/7274183/php-convert-unicode-to-character . Hope this helps. -- Richard Quadling Twitter : @RQuadling Can you show exactly what is produced? I'm guessing your KDE console is not set to UTF-8. I'm on a Mac, so I'm not able to help with that other than maybe http://www.linuxquestions.org/questions/linux-software-2/kde-and-utf8-276033/ -- Richard Quadling Twitter : @RQuadling Of course! Glad to have helped. -- Richard Quadling Twitter : @RQuadling
Re: [PHP] [ask] convert unknown Korean's string to readable string
On 29 April 2013 20:38, Morning Star morning.star.c...@gmail.com wrote: Thanks, Richard. It works in xterm, but it doesn't work in KDE konsole. i don't know how to figure it out. help me Best regards, Marco On Mon, Apr 22, 2013 at 9:43 AM, Richard Quadling rquadl...@gmail.com wrote: On 18 April 2013 08:06, Morning Star morning.star.c...@gmail.com wrote: $string = \uc548\ub155\ud558\uc138\uc694 ?php $string1 = '\uc548\ub155\ud558\uc138\uc694'; $string2 = preg_replace('/\\\u([0-9a-f]+)/', '#x$1;', $string1); $string3 = html_entity_decode($string2, ENT_COMPAT, 'UTF-8'); echo 'Original : ', $string1, PHP_EOL, 'Entities : ', $string2, PHP_EOL, 'Decoded : ', $string3, PHP_EOL, PHP_EOL; ? outputs (at least for me) ... 안녕하세요 Based upon http://stackoverflow.com/questions/7274183/php-convert-unicode-to-character . Hope this helps. -- Richard Quadling Twitter : @RQuadling Can you show exactly what is produced? I'm guessing your KDE console is not set to UTF-8. I'm on a Mac, so I'm not able to help with that other than maybe http://www.linuxquestions.org/questions/linux-software-2/kde-and-utf8-276033/ -- Richard Quadling Twitter : @RQuadling
Re: [PHP] mysql_connect noob question
Completely different function call(). mysql_connect() - the port is part of the host. *server* The MySQL server. It can also include a port number. e.g. hostname:port or a path to a local socket e.g. :/path/to/socket for the localhost. If the PHP directive mysql.default_hostitss://chm/res/mysql.configuration.html#ini.mysql.default-hostis undefined (default), then the default value is 'localhost:3306'. In SQL safe mode itss://chm/res/ini.core.html#ini.sql.safe-mode, this parameter is ignored and value 'localhost:3306' is always used. mysqli_connect() - the port is a parameter. I think you got the answers to the question you asked. On 23 April 2013 18:14, Jim Giner jim.gi...@albanyhandball.com wrote: On 4/23/2013 10:39 AM, Glob Design Info wrote: Well all, it turns out the *correct* answer to my question, which no one answered, and which only degenerated into a kindergarten-like argument is: You need to add the port # to the *end* of the mysql_connect() call. i.e.: $link = mysqli_connect( $host, user, pass, $database, $port ); Glad to see the maturity level of posters on this list, as in most of IT these days is that of a bunch of squabling 5-year olds. On 4/23/13 5:47 AM, Tedd Sperling wrote: On Apr 21, 2013, at 3:33 PM, Glob Design Info i...@globdesign.com wrote: What question did I not answer? That proves that you're not listening -- you are total waste of time for anyone trying to help. Welcome to my ignore file. tedd _ tedd.sperl...@gmail.com http://sperling.com Tedd - you got off easy on this post. You should have seen the shouting tirade I received offline from this guy. What a putz! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP] [ask] convert unknown Korean's string to readable string
On 18 April 2013 08:06, Morning Star morning.star.c...@gmail.com wrote: $string = \uc548\ub155\ud558\uc138\uc694 ?php $string1 = '\uc548\ub155\ud558\uc138\uc694'; $string2 = preg_replace('/\\\u([0-9a-f]+)/', '#x$1;', $string1); $string3 = html_entity_decode($string2, ENT_COMPAT, 'UTF-8'); echo 'Original : ', $string1, PHP_EOL, 'Entities : ', $string2, PHP_EOL, 'Decoded : ', $string3, PHP_EOL, PHP_EOL; ? outputs (at least for me) ... 안녕하세요 Based upon http://stackoverflow.com/questions/7274183/php-convert-unicode-to-character. Hope this helps. -- Richard Quadling Twitter : @RQuadling
[PHP] OAuth test server and help my slow brain understand what I'm doing.
Hi. I've been tasked to integrate some financial data into our site. The provider uses a 2 legged OAuth mechanism for the security. I have my consumer key and secret and the service end point, but I'm at a loss to even know if I'm doing anything right. Does anyone have a script that uses 2 legged OAuth I can use to make sure I'm doing it right and to be able to just substitute my keys and end point as a test to the service I need. Alternatively, if any one has done a 2 legged OAuth using pecl/oauth, then please can you give me a few pointers! Any help would be great! Regards, Richard.
Re: [PHP] variable type - conversion/checking
On 15/03/2013 22:00, Ashley Sheridan wrote: On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int I'm late in on this thread so apologies if I have missed something here .. but wouldn't is_int() do what the OP wants? rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reflecting Constants.
On 12 March 2013 14:01, Tomasz Sawicki falun...@gmail.com wrote: It would seem that without tokenising the class file, I'm sort of stuck with the solution I've got at the moment. Unless anyone has any ideas! I faced similar problem with constants when doing WSDL generator. In my case I wanted to extract constant description to include it in WSDL documentation section. Unfortunately PHP Reflection API exposes only ReflectionClass::getConstants method which doesn't return PHPDoc comments. My solution was to put following annotation in class PHPDoc for each constant in the class: @constant CONSTANT_NAME Description of constant. Of course you need to keep constant names in PHPDoc synchronised with code, but in my case this annotation is required for every constant so I get notified about any problems with it. -- Tomasz Sawicki This is a good idea. It will allow me to use ReflectionClass-getDocComment() It does require the constant name to be present @vanity CONSTANT_NAME LONG_NAME,SHORT_NAME,HUMAN_NAME I've implemented this and it is working. I've @todo'd it to refactor if PHP has a ReflectionConstant class at some stage in the future. Thanks. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML to Array
On 10/03/2013 11:47, Karl DeSaulniers wrote: Hi Guys, I am hoping someone can guide me or help me fix this issue. I have been lost in the code for some time now. I am trying to get the attributes of an xml node. I have this code: [snip] this may help - http://stackoverflow.com/questions/1156957/php-xml-attribute-parsing I do admit I haven't the foggiest idea what I am doing here, so I am noobing out here on how this php function is really working. I got it off php.net and am trying to implement it in my code. Without my addition it works well except it doesn't grab any attributes which I need in order for my script to work properly. Any ideas on what I am doing wrong? TIA, HTH rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very Large File Splatter
On 22 February 2013 21:04, Brian Smither bhsmit...@gmail.com wrote: PHP 5.4.4-TS-VC9 on Windows XP SP3 NTFS non-system drive with 18GB free. I dare not try to replicate this. As such, I cannot firmly place the blame on PHP. I have peppered a PHP application with a call to a function which appends-only to a logfile the parameters passed to it. Each pass of the application creates many MB of content. It is conceivable that I ran out of hard drive space. When that which what I was working on seemed to be acting very weird, I rebooted the computer only to see thousands of lines scroll by from Windows repairing the file system. I discovered logfile contents in many dozens of files. The timestamp and filesize of the damaged files were not changed. Only the contents replaced with slices of the logfile. Again, I'm not going to try to 'intentionally' replicate this, so I ask: Has PHP's interface with the NTFS file sub-system ever been reported to splatter a file across the contents of a drive? At this stage, the safest option is a restore from your backups. Cross linked files often mean the tail end of one of the cross linked files is now orphaned. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Holding datetimes in a DB.
On 1 March 2013 10:49, Richard Quadling rquadl...@gmail.com wrote: Hi. My heads trying to remember something I may or may not have known to start with. If I hold datetimes in a DB in UTC and can represent a date to a user based upon a user preference Timezone (not an offset, but a real timezone : Europe/Berlin, etc.) am I missing anything? Richard. Thank you to everyone who pitched in. My initial assumptions seem to hold. Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wrong time being displayed by PHP!
On Thu, Oct 18, 2012 at 2:12 AM, Ford, Mike m.f...@leedsmet.ac.uk wrote: From: underp...@gmail.com [mailto:underp...@gmail.com] On Behalf Of Richard S. Crawford Sent: 17 October 2012 19:29 To: PHP-General You can see the current output of the above code here: http://projectbench.extensiondlc.net Can I ask what the fix for this was? Because that URL is currently showing the following for me: 02:09:27 am America/Los_Angeles America/Los_Angeles Thu, 18 Oct 2012 02:09:27 -0700 Thu, 18 Oct 2012 09:09:27 + 1350551367 (-25200) Thu Oct 18 02:09:27 PDT 2012 Cheers! Mike Hi Mike, Sorry I took so long to answer. I've been out sick, and didn't have access to the resolution information until this morning. The server administrators wound up reinstalling the tzdata package and enabled time synchronization. -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
Re: [PHP] Wrong time being displayed by PHP!
On Tue, Oct 16, 2012 at 3:16 PM, Daniel Brown danbr...@php.net wrote: With regard to debugging your issue, it's extremely unlikely that it's PHP's fault, since no one else has the same issue. However, it does indeed sound as though there's a configuration mismatch or a bad setting of the system clock (as suggested earlier by myself and others). What's the output when you run the code below? ?php if (php_sapi_name() == 'cli') { define('NL',PHP_EOL); } else { define('NL','br/'.PHP_EOL); } echo date_default_timezone_get().NL; echo date('r').NL; echo gmdate('r').NL; echo time().' ('.date('Z').')'.NL; echo trim(`date`).NL; ? This is the output: America/Los_Angeles Tue, 16 Oct 2012 17:22:09 -0400 Tue, 16 Oct 2012 21:22:09 + 1350422529 (-14400) Tue Oct 16 17:22:09 EDT 2012 Is this a shared server, Rich? As shown, the admin configured the timezone of the machine to be EDT and set the clock right, but php.ini must be set to PDT. You can easily override this with a local php.ini file, an .htaccess directive, or by placing date_default_timezone_set() near the top of the code. You can see the current output of the above code here: http://projectbench.extensiondlc.net I've confirmed that the server is set to PDT. The value of date.timezone in php.ini is America/Los_Angeles, which should be (currently) -8 hours from UTC, but it looks like the PDT offset is only set to -4. Does that even make sense? -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
[PHP] Wrong time being displayed by PHP!
The value of date.timezone in php.ini is set to America/Los_Angeles. The local time is 11:02 a.m. Yet the output of date(h:i a e) is: 02:02 pm America/Los_Angeles which is three hours ahead of the real time. Why is this? What's going on? -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Twitter: http://twitter.com/underpope Facebook: http://www.facebook.com/underpope Google+: http://gplus.to/underpope
Re: [PHP] Wrong time being displayed by PHP!
I double checked the server time. It is set to America/Los_Angeles as well. On Tue, Oct 16, 2012 at 11:07 AM, Adam Richardson simples...@gmail.comwrote: On Tue, Oct 16, 2012 at 2:02 PM, Richard S. Crawford rich...@underpope.com wrote: The value of date.timezone in php.ini is set to America/Los_Angeles. The local time is 11:02 a.m. Yet the output of date(h:i a e) is: 02:02 pm America/Los_Angeles which is three hours ahead of the real time. Why is this? What's going on? The server's time could be wrong. Or, code somewhere could be (re)setting the timezone. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
Re: [PHP] Wrong time being displayed by PHP!
On Tue, Oct 16, 2012 at 12:42 PM, Enrico Lamperti z...@irken.com.ar wrote: You could try using date_default_timezone_set http://php.net/manual/en/function.date-default-timezone-set.php() in your script, instead. And if you don't need to care about DST, you can define a specific GMT offset http://www.php.net/manual/en/timezones.others.php. Hope it helps :) Hi Enrico, Thanks for the suggestion. Unfortunately the problem seems to be that PHP thinks the America/Los_Angeles timezone is the same as EDT. I'm not sure how to approach this issue. Richard On Tue, Oct 16, 2012 at 3:56 PM, Richard S. Crawford rscrawf...@mossroot.com wrote: I double checked the server time. It is set to America/Los_Angeles as well. On Tue, Oct 16, 2012 at 11:07 AM, Adam Richardson simples...@gmail.com wrote: On Tue, Oct 16, 2012 at 2:02 PM, Richard S. Crawford rich...@underpope.com wrote: The value of date.timezone in php.ini is set to America/Los_Angeles.. The local time is 11:02 a.m. Yet the output of date(h:i a e) is: 02:02 pm America/Los_Angeles which is three hours ahead of the real time. Why is this? What's going on? The server's time could be wrong. Or, code somewhere could be (re)setting the timezone. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com ) -- Enrico -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
Re: [PHP] Wrong time being displayed by PHP!
On Tue, Oct 16, 2012 at 2:05 PM, Daniel Brown danbr...@php.net wrote: On Tue, Oct 16, 2012 at 4:19 PM, Richard S. Crawford rscrawf...@mossroot.com wrote: Thanks for the suggestion. Unfortunately the problem seems to be that PHP thinks the America/Los_Angeles timezone is the same as EDT. I'm not sure how to approach this issue. Per list rules, just a gentle reminder: please don't top-post. Sorry about that. I was getting very frustrated with the issue, and I forgot. I'll be sure to keep it in mind. With regard to debugging your issue, it's extremely unlikely that it's PHP's fault, since no one else has the same issue. However, it does indeed sound as though there's a configuration mismatch or a bad setting of the system clock (as suggested earlier by myself and others). What's the output when you run the code below? ?php if (php_sapi_name() == 'cli') { define('NL',PHP_EOL); } else { define('NL','br/'.PHP_EOL); } echo date_default_timezone_get().NL; echo date('r').NL; echo gmdate('r').NL; echo time().' ('.date('Z').')'.NL; echo trim(`date`).NL; ? http://www.php.net/unsub.php This is the output: America/Los_Angeles Tue, 16 Oct 2012 17:22:09 -0400 Tue, 16 Oct 2012 21:22:09 + 1350422529 (-14400) Tue Oct 16 17:22:09 EDT 2012 -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
Re: [PHP] Friday - Return of Brain Teasers
Christopher Walken? Is that you? On Fri, Oct 5, 2012 at 10:43 AM, Daniel Brown danbr...@php.net wrote: About five-and-a-half years ago, we had a brainteasers thread going on[1]. Last year it was briefly resurrected[2], and both times got some good content and dialogue going. So I'd like to reprise the thread in 2012, as well. Those of you connected to me on Facebook (parasane) or Twitter (@oidk) might already have seen it, but a simple one to get things rolling: ?php require ++$cowbell; ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
[PHP] Using a stream filter to do a search and replace on an XML file.
Hello. Just learning about stream filtering and have 2 questions I hope someone can give me some pointers on. 1 - Bucketing. In reading a bit about how this works, the data is passed in chunks through the filter - known as a bucket brigade. How does this work if, for example, the search string is chopped by the bucketing system? It would seem that you would end up with 2 parts of the search element, neither would be matched for replacing and then the whole element would be reconstituted in the output. My filter method is ... function filter($r_In, $r_Out, $i_Consumed, $b_Closing) { while ($o_Bucket = stream_bucket_make_writeable($r_In)) { $o_Bucket-data = preg_replace('`(/?)(\d+)`', '$1fixed_$2', $o_Bucket-data); $i_Consumed += $o_Bucket-datalen; stream_bucket_append($r_Out, $o_Bucket); } return PSFS_PASS_ON; } This is working fine (so far as I can tell as SimpleXMLIterator is now happy to read the XML file), but I'm guessing I'm missing something here if my understanding is correct. 2 - Stream wrapping. At the moment, we download a .gz file and decompress it into the .xml file. I know I can use a zlib:// stream wrapper to save me having to decode the .gz file first. This means smaller downloads and less storage. We can even use the zlib:// filter on the URL, but we cache the .gz file locally, so that isn't important. But for a small set of files (their origin is known, so I can create a rule for this issue), I have to expand the .gz file first and then fix the file using the filter above. I then have two paths to load the xml - either a zlib:// decompress stream or a straight local file. I'd like to work out how to create a stream wrapper to allow me to say SOMETHING like ... $o_MySXI = new SimpleXMLIterator('xml.NoNumericTags://compress.zlib:///development/BadlyFormed.gz'); If this was possible, I'd be a LOT happier and could simply stream from the .gz files without needing to hold onto anything. Ideas/suggestions/examples/code gratefully received. Regards, Richard. -- Richard Quadling Twitter : EE : Zend : Fantasy Shopper @RQuadling : http://e-e.com/M_248814.html : http://bit.ly/9O8vFY : http://fan.sh/106/5tw -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL and PHP weirdness - RESOLVED
This has been resolved. A previous programmer had snuck in a function that would convert the value of the description field to a date value if it contained the word Date. This has been fixed. On Tue, Feb 14, 2012 at 5:44 PM, David Robley robl...@aapt.net.au wrote: Richard S. Crawford wrote: Bear with me here. I have a problem with PHP and MySQL that's been stumping me for a couple of days now. I'm not even sure how to describe it, so I'll just do my best. There's a row in our bugs database that looks like every other row in the table, but when it's pulled from the database and displayed in PHP, the description field -- which is defined as a mediumtext field -- is displayed as a date field with a value of 12/31/1969. Moreoever, when I use PHPMyAdmin to look at the row directly, the description field has the data that I expect it to. Just for fun, here's the text in question: Quarterly Course Set Up - Spring 2012 (114) Section Course titleCourse Start Date 114MHI214 The Internet and the Future of Patient Care 04/02/2012 114MHI212 Health Information Systems Analysis and Design 04/02/2012 Program administrator 2 users; Laurel Aroner - Susan Catron - Jennifer Kremer Instructors; MHI214; Peter Yellowlees MHI212; Robert Balch Per instructions from Rita Smith-Simms - I'm creating this task for myself and based on instructions given which are that all listed courses are now to be backed-up and restored sooner (original course set up time-frame was a month before course starts). Adding instructions - Follow the 52-step quarterly course set up process and information from the course matrix; if matrix incomplete, input information during this set up As you track your time each day, please include in the notes which courses (use project code) you worked on and indicate either working on or completed. Create and notify by 2/15/2012 I've made sure there are no odd characters that would mess up how PHP is displaying the text. I've tried changing the field type from mediumtext to text but this didn't work. If anyone has any ideas as to why this might be happening -- or if I just wasn't clear -- please let me know. If phpmyadmin gives expected results and _your_ code doesn't, I'd be suspicious of your code :-) It might be helpful for you to post relevant part(s) ofthe actual code you are using. Cheers -- David Robley Man who run behind car get exhausted. Today is Sweetmorn, the 46th day of Chaos in the YOLD 3178. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
[PHP] MySQL and PHP weirdness
Bear with me here. I have a problem with PHP and MySQL that's been stumping me for a couple of days now. I'm not even sure how to describe it, so I'll just do my best. There's a row in our bugs database that looks like every other row in the table, but when it's pulled from the database and displayed in PHP, the description field -- which is defined as a mediumtext field -- is displayed as a date field with a value of 12/31/1969. Moreoever, when I use PHPMyAdmin to look at the row directly, the description field has the data that I expect it to. Just for fun, here's the text in question: Quarterly Course Set Up - Spring 2012 (114) Section Course titleCourse Start Date 114MHI214 The Internet and the Future of Patient Care 04/02/2012 114MHI212 Health Information Systems Analysis and Design 04/02/2012 Program administrator 2 users; Laurel Aroner - Susan Catron - Jennifer Kremer Instructors; MHI214; Peter Yellowlees MHI212; Robert Balch Per instructions from Rita Smith-Simms - I'm creating this task for myself and based on instructions given which are that all listed courses are now to be backed-up and restored sooner (original course set up time-frame was a month before course starts). Adding instructions - Follow the 52-step quarterly course set up process and information from the course matrix; if matrix incomplete, input information during this set up As you track your time each day, please include in the notes which courses (use project code) you worked on and indicate either working on or completed. Create and notify by 2/15/2012 I've made sure there are no odd characters that would mess up how PHP is displaying the text. I've tried changing the field type from mediumtext to text but this didn't work. If anyone has any ideas as to why this might be happening -- or if I just wasn't clear -- please let me know. -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Twitter: http://twitter.com/underpope Facebook: http://www.facebook.com/underpope Google+: http://gplus.to/underpope
Re: [PHP] How to find where class is used?
On 06/01/2012 12:11, Dotan Cohen wrote: In a large application that I am tasked with maintaining (vBulletin) there is a particular class that is used: vB_ProfileBlock_VisitorMessaging. I know the file that it is defined in, but I cannot find the file that actually creates a vB_ProfileBlock_VisitorMessaging object. I tried the brute-force grep approach, but the only place where I see the class mentioned is in the class declaration itself: [dev@localhost forum]$ grep -ir vB_ProfileBlock_VisitorMessaging * includes/class_profileblock.php:class vB_ProfileBlock_VisitorMessaging extends vB_ProfileBlock I know that this class is used as there is a page that is obviously using it. I have tried playing be-the-PHP-parser with that file, but it goes on to include() about a dozen other files, each of which include() another dozen files! This server does not and cannot have a debugger. What else can I do to find where this class object is created? Thanks. Can you not put a debug_print_backtrace() in the class constructor? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOS CLI?
On 2 December 2011 21:00, Matt Neimeyer m...@neimeyer.org wrote: Is there (or is there a way to compile) a DOS CLI version of a fairly recent version of PHP? I have not been able to find one using the powers of Google. Not a Windows Command Prompt CLI but an actual CLI version of PHP that can be made to run in a real DOS environment? I'm sure I could find another scripting language for DOS but to prototype this project I'd like to not have to learn a new language as well. :) Thanks in advance for ANY suggestions. Matt According to http://en.wikipedia.org/wiki/MSDOS#Versions, the last retail version of DOS would be V6.22, though V7.1 was the last one to be used as a Windows loader. But I have no idea what compiler could be used. MSDOS has no built in network support, so advanced memory management, etc. Not without having to load additional drivers and the TCP/IP drivers for MS DOS are not tiny. Sure, you really can (and I have) cram then into upper memory, but it is on a motherboard by motherboard basis - one size does not fit all. All of these things would severely cripple PHP's usage in a true MSDOS environment. Add to that, the vast majority of libraries will be talking to the windows api in some form and that doesn't exist. You are pretty much stuck with no network services, limited memory and restricted extensions. Can you describe your project and to why it MUST run on such an ancient OS? OOI, Using something like DosBox [1] can help with some development - a DOS emulator for Windows. I use it to run REALLY old games. Richard. [1] http://www.dosbox.com/ -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
On 29/11/2011 17:16, Daniel Brown wrote: On Sat, Nov 19, 2011 at 09:33, richard grayr...@richgray.com wrote: This happens because PHP is writing to STDOUT, of course, and then the command line redirection grabs that information and puts it into the file. Unfortunately, by itself, this won't work in the background, which is why you're getting the SIGTTOU (SIGnal TTy OUput). If you need to redirect the output and have it run in the background (where something like file_put_contents() or fwrite() isn't a practical option), give it a NOHUP (NO Hang-UP): nohup php test.php test.log This will automatically redirect STDERR to STDOUT, save for the message telling you the same. Thanks for your reply Daniel unfortunately nohup makes no difference the script still stops with no output being logged -- and also on a different machine (Ubuntu) php -f test.php test.log 21 -- works perfectly - seems to be an issue with OSX Lion and the version of PHP that came with the machine -- I cannot compile my own build of PHP because of this problem - https://bugs.php.net/bug.php?id=60268 -- so I am completely stuck :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
On 23/11/2011 18:49, Alain Williams wrote: On Wed, Nov 23, 2011 at 06:14:07PM +0100, richard gray wrote: Reading symbols for shared libraries + done 0x000101d057ee in __ioctl () Any clues? To me it looks like PHP cli is trying to do some I/O but I'm just a dumb developer... :) ioctl on a tty is typically used to set it into single character at a time mode (remove stty's icanon). It could have decided that since it is a tty then that should be set. You need a bit more info, get a backtrace with 'where'. Thanks for the response Alain - below is the output:- [rich@LeMans] (/Web/scripts) gdb --pid=3294 GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type show copying to see the conditions. There is absolutely no warranty for GDB. Type show warranty for details. This GDB was configured as x86_64-apple-darwin. /Web/scripts/3294: No such file or directory Attaching to process 3294. Reading symbols for shared libraries . done Reading symbols for shared libraries done Reading symbols for shared libraries + done 0x7fff8f8ac7ee in __ioctl () (gdb) where #0 0x7fff8f8ac7ee in __ioctl () #1 0x7fff8f8ac1fe in ioctl () #2 0x7fff910a6b1c in tcsetattr () #3 0x00010ab05df7 in tty_end () #4 0x00010ab05c39 in tty_init () #5 0x00010aaf7261 in el_init () #6 0x00010aafeb8e in rl_initialize () #7 0x00010a3ef39a in zm_startup_readline () #8 0x00010a37a1c8 in zend_startup_module_ex () #9 0x00010a38166b in zend_hash_apply () #10 0x00010a37d3dd in zend_startup_modules () #11 0x00010a3287bf in php_module_startup () #12 0x00010a3ef637 in php_cli_startup () #13 0x00010a3efff8 in main () -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
On 23/11/2011 11:05, Laruence wrote: Hi: I mean, do you built your php with readline support, or do you load readline.so into PHP? if so, remove it, then try again. and you also can use: gdb --pid={the pid of the stopped php} then you will find where the php hangs. thanks I didn't build PHP as it fails to make -- see https://bugs.php.net/bug.php?id=60268 so I am stuck with the PHP build provided by Apple... :( Here's what gdb says [rich@LeMans] (/web/scripts) php -f test.php test.log 21 [1] 3513 [rich@LeMans] (/web/scripts) [1]+ Stopped php -f test.php test.log 21 [rich@LeMans] (/web/scripts) gdb --pid 3513 GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type show copying to see the conditions. There is absolutely no warranty for GDB. Type show warranty for details. This GDB was configured as x86_64-apple-darwin. /Web/scripts/3513: No such file or directory Attaching to process 3513. Reading symbols for shared libraries . done Reading symbols for shared libraries done Reading symbols for shared libraries + done 0x000101d057ee in __ioctl () Any clues? To me it looks like PHP cli is trying to do some I/O but I'm just a dumb developer... :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
On 22/11/2011 05:51, Laruence wrote: did you run php with readline? try run the script without php-readline. thanks No - the script was just a basic string echo - no readline was involved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
On 19 November 2011 14:33, richard gray r...@richgray.com wrote: Hi all Hope someone can help me with a weird issue I have... I am trying to run a php CLI script in the background and it just won't run - it has a status of Stopped SIGTOU (Trying to write output) - Here are the details OS Mac OS X Lion 10.7.2 PHP PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep 8 2011 19:34:00) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies I created a basic script test.php ?php echo 'Hello world'.PHP_EOL; ? Here are the results of various tests:- Test 1) php -f test.php (Hello world gets displayed) Test 2) php -f test.php test.log 21 (Hello world gets put into test.log) Test 3) php -f test.php test.log 21 --- I get [1]+ Stopped(SIGTTOU) php -f test.php test.log 21 -- and the job just sits there doing nothing nothing gets logged however lsof shows the log file is open It is something to do with php because a similar shell script gets executed no problems in the background... This has me stumped ... any ideas? TIA Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I've seen this ... php script.php 1nul 2nul Not sure how effective it is. But the code is tagged as a fire and forget mechanism. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP script won't run in the background
Hi all Hope someone can help me with a weird issue I have... I am trying to run a php CLI script in the background and it just won't run - it has a status of Stopped SIGTOU (Trying to write output) - Here are the details OS Mac OS X Lion 10.7.2 PHP PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep 8 2011 19:34:00) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies I created a basic script test.php ?php echo 'Hello world'.PHP_EOL; ? Here are the results of various tests:- Test 1) php -f test.php (Hello world gets displayed) Test 2) php -f test.php test.log 21 (Hello world gets put into test.log) Test 3) php -f test.php test.log 21 --- I get [1]+ Stopped(SIGTTOU)php -f test.php test.log 21 -- and the job just sits there doing nothing nothing gets logged however lsof shows the log file is open It is something to do with php because a similar shell script gets executed no problems in the background... This has me stumped ... any ideas? TIA Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
On 19/11/2011 16:09, Laruence wrote: $ stty -tostop makes no difference # stty -tostop # php -f test.php test.log 21 # jobs # [1]+ Stopped(SIGTTOU)php -f test.php test.log 21 Any other ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP script won't run in the background
Laruence, while that may be a helpful answer to a few people in the know, just replying back with a single line like that isn't really going to help the people who are having this problem. At least explain why you suggested that, or what it does for those on the list that don't know, especially as it's not a PHP thing, it's a Unix command thing. Richard, some more info on the command Laruence mentioned can be found at http://docstore.mik.ua/orelly/unix/upt/ch12_07.htm which explains it in more detail. not sure this is relevant as my script is not trying to write to the terminal the test.log 21 is sending stdout and stderr to the log file not the tty... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] {} forms
On 16 November 2011 13:56, Tim Streater t...@clothears.org.uk wrote: I'm looking at the source of a web sockets server and I see these various forms: ws://{$host}{$path} HTTP/1.1 ${status}\r\n Are these simply equivalent to: ws:// . $host . $path HTTP/1.1 . $status . \r\n; and if so, is there any particular benefit to using that form? Or if not, what do they mean? (I've read up about variable variables). Thanks, -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you want to embed $array[CONSTANT], then the {} is used. I use {} out of habit for non arrays. Not sure if there is an impact. http://docs.php.net/manual/en/language.types.string.php#example-71 shows the use. Oh. I've fixed the layout bug for http://docs.php.net/manual/en/language.types.string.php#example-70. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using SimpleXMLIterator with a Iterator Filter.
Hi. I can never seem to get the SPL right in my head. So, I hope someone can help. I have many XML streams that I can use SimpleXMLIterator on. Each streams is structured slightly differently. Some streams contain unused data and may or may not hold the data at the same level in the stream. I need to be able to filter out specific nodes on a per stream basis. So, for example, in 1 stream, I only want to examine the /entry nodes, not the /title, /id nodes. In another, only the /products/product nodes. Currently, code along the lines of the snippet below is functional ... ?pseudo-php // Get the stream. $o_Stream = new SimpleXMLIterator($s_URL, 0, True); // Add an xpath() filter if necessary. if ('' === $s_URL) { $o_Stream-xpath('/products'); } ... (repeat as required for each URL that requires it) // Iterate the stream. foreach($o_Stream as $s_Tag = $o_Element) { // Filter out the unwanted tags, based upon the stream url. if ('' === $s_URL 'entry' === $s_Tag) { // Process $o_Element $o_Product = new \FS\Product(); $o_Product-id = (string)$o_Element-id; ... (process the remaining properties of the element into the product). } ... (repeat the filtering of the tags for each stream url) } ? Whilst the code above works it is unwieldy and is getting more and more complex as new streams become available. And so I need to refactor it. I would like to remove the specifics of the filtering and the processing to a point that I can take a feed URL and a filter and get back Products, irrespective of the feed or filter. e.g. ?php // Iterate the DB, getting the FilterClassName and the associated URL. foreach($o_DB-getStreams() as $o_StreamInfo) { // Iterate the products for the URL (post filtering). foreach(new $o_StreamInfo-s_FilterClassName($o_StreamInfo-s_FeedUrl) as $o_Product) { // The product is standardised irrespective of the feed or the filter. } } ? (As an aside, the $o_StreamInfo-s_FilterClassName($o_StreamInfo-s_FeedUrl) line works fine. A property of a class containing the name of a class to be instantiated.) I cannot work out do I use FilterIterator or RecursiveFilterIterator or something other. I expect to have at least 1 concrete class per filter - some will be shared amongst multiple streams. There may be an abstract base class to consolidate any duplication. I may also need a mapper class to take the data from the stream and present it as a standardised Product. I suppose they are 2 separate concerns and could be treated as such. At the moment, I do not have a need to have a mapper apply to different streams structures, so combining the mapper and the filter into 1 entity does work with the existing data I have. But I think having them separate will help in the long run. But I just can't seem to get my head around this. I think applying a filter to the SimpleXMLIterator is causing the filter to examine every node. This is not what I want. Any ideas, suggestions, reading. I've got the manual but the iterator documentation isn't great. I don't know who knows this stuff inside out, or how to describe things in a useful way for the documentation. So. Help! Regards, Richard Quadling. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
On 15 November 2011 11:50, a dehqan dehqa...@gmail.com wrote: \n is for Linux \r is for Windows On 11/14/11, Richard Quadling rquadl...@gmail.com wrote: On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 No, \r is the requirement of the modem. Nothing to do with the OS. Windows uses \r\n as its line terminators, but when you talk to a modem, you use \r. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
On 15 November 2011 15:12, Mike Mackintosh mike.mackint...@angrystatic.com wrote: On Nov 15, 2011, at 8:25, Richard Quadling rquadl...@gmail.com wrote: On 15 November 2011 11:50, a dehqan dehqa...@gmail.com wrote: \n is for Linux \r is for Windows On 11/14/11, Richard Quadling rquadl...@gmail.com wrote: On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 No, \r is the requirement of the modem. Nothing to do with the OS. Windows uses \r\n as its line terminators, but when you talk to a modem, you use \r. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I've had better luck with PHP_EOL instead of \r or \n. I think I've not explained myself properly. The modem wants a carriage return. That is a \r. It doesn't matter what OS you are on. If you don't send the right string to the modem, then the modem won't process it properly. If your OS maps \r to PHP_EOL, then, obviously PHP_EOL will be just fine. But I would recommend ... ?php define('CR', chr(13)); ? -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] json_encode confusion
On 10 November 2011 14:45, Bastien Koert phps...@gmail.com wrote: Morning all, I've been having some fun with converting a text data file import into a json object for storage. I have a text file that is pipe delimited coming in via an upload. The first row is the headers and the second row is the data. Using this code: $data = file(inline_Nov_8_2011.txt); if(count($data)==2){ $keys = explode(|, $data[0]); $fields = explode(|, $data[1]); $combine = array_combine($keys, $fields); $json = json_encode($combine); } After the combine, I get an array that looks like this Array ( ['Legal Last Name '] = Andros ['Legal Middle Initial '] = ['Legal First Name '] = Marisa ['Maiden/Other Name '] = ['Social Insurance No. '] = 123456789 ['Date of Birth '] = 2/1/1988 ['Gender '] = Female ) But the json encoded value looks like this (there are way more elements but this should be enough to represent what I need to do). {null:Andros,null:,null:Marisa,null:,null:123456789,null:2\/1\/1988,null:Female} I have been googling for info about allowed values for the json keys, but can't seem to find a clear doc on what is allowed and what isn't. I have tried unquoted keys, replaced the spaced with underscores but nothing I do seems to help. When I echo out the json encoded data, the keys are all nulls. Can someone point me in the correct direction? It may be that I need to manually create the key names as an array first, which I was hoping to avoid since the file format coming from the client is still in some flux. ?php $data = array( 'Legal Last Name ' = 'Andros', 'Legal Middle Initial ' = '', 'Legal First Name ' = 'Marisa', 'Maiden/Other Name ' = '', 'Social Insurance No. ' = 123456789, 'Date of Birth ' = '2/1/1988', 'Gender ' = 'Female' ); echo json_encode($data, JSON_FORCE_OBJECT); ? outputs ... {Legal Last Name :Andros,Legal Middle Initial :,Legal First Name :Marisa,Maiden\/Other Name :,Social Insurance No. :123456789,Date of Birth :2\/1\/1988,Gender :Female} -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pcre little problem
On 4 November 2011 16:52, QI.VOLMAR QI qi.vol...@gmail.com wrote: i have this part of code that works with DOMDocument: public function translateNFeXML(NFE $nfe_factory) { $inf_adic = $nfe_factory-createElement('infAdic'); if ($this-inf_ad_fisco) { $inf_adic_fisco = $nfe_factory-createElement('infAdicFisco', $this-inf_ad_fisco); $inf_adic-appendChild($inf_adic_fisco); } $string = a=10b[]=20c=30n°d=40+:50; die(preg_filter('/[^:][[:punct:]]/', '', $string)); $inf_cpl = $nfe_factory-createElement('infCpl', $this-inf_complementar); QUESTION: Why the preg_filter causes a end of the application, with no error throwing (even in die don't appears nothing)? preg_filter() returns NULL if there are no matches and the subject is a string. And ... php -r die(null); outputs nothing. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370
Re: [PHP] Regular Expression
On 5 November 2011 05:39, Negin Nickparsa nickpa...@gmail.com wrote: your welcome my Friend,I used it myself. On 11/4/11, drive view drivev...@gmail.com wrote: Thanks alot Negin for the prompt reply. This is most useful. Regards Best Toni On Sat, Nov 5, 2011 at 6:30 AM, Negin Nickparsa nickpa...@gmail.com wrote: http://weblogtoolscollection.com/regex/regex.php On 11/4/11, drive view drivev...@gmail.com wrote: Hi I'm new to PHP. I'm currently trying understand how to apply the patterns for the preg* commands and I am having difficulty finding a good source explaining in detail how to build a filter. I would appreciate if someone can direct me to such a website. Thanks Toni -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I use http://www.regular-expressions.info The site's author also has a book which I would recommend : http://www.regular-expressions.info/cookbook.html -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370
Re: [PHP] Convert Hours to Decimal
On 17 October 2011 22:57, Don Wieland d...@dwdataconcepts.com wrote: select timediff(cast(out_1 as time), cast(in_1 as time)) tHours FROM lm_tc_trans WHERE tc_trans_id = '42' Can you try ... SELECT CAST ( TIMEDIFF ( CAST(Out_1 AS Time), CAST(In_1 AS Time) ) AS Decimal(5,2) ) tHours FROM lm_tc_trans WHERE tc_trans_id = '42' Basically, CAST the result back to a decimal(5,2) -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Friday Distraction
On 21 October 2011 17:27, Daniel Brown danbr...@php.net wrote: I'll get this week's Friday distraction kicked off here with something shared with me by a Facebook friend. If you're on Facebook, try this. It's pretty sweet (and safe for work and kids). http://www.takethislollipop.com/ Sweet? SWEET!? What sort of sicko are you??? I've got a deranged nutter hunting me down. He looks a LOT like you Cool though. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Processing newlines in a text area field
On 14 October 2011 03:49, Stephen stephe...@rogers.com wrote: I have a web page with a form with a text area. I enter: foo bar PHP processes the POST and inserts the record into MySQL. The database field is text. I use PDO For testing I have removed any processing of the text area content. Now, no matter how many blank rows I have between foo and bar, in the database record, I always get a single newline character. I am using Firefox 7.0.1. Is this normal behaviour? I want to be able to enter more than 1 newline. Thanks Stephen What is the wrap attribute set to on the textarea? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to know the path of `php.ini` used when call php.exe from CLI/command-line in Windows 7
On 11 October 2011 19:40, Nam Gi VU nam.gi...@gmail.com wrote: Hi every one, Currently when I call php --ini from CLI, I just see C:\Windows but search for this location, I cannot find any php.ini files. I'm stuck there - where is the php.ini file used by php.exe called from CLI as below *C: php --ini* The following documentation links are all relevant. http://docs.php.net/manual/en/install.windows.manual.php http://docs.php.net/manual/en/install.windows.commandline.php http://docs.php.net/manual/en/configuration.file.php -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CGI PHP vs. FastCGI vs. mod_php vs. application server?
On 12 October 2011 09:19, saeed ahmed saeed@gmail.com wrote: greeting all, As far as I know, there are different ways to write a PHP application: - CGI, ie. the usual way : some PHP code in web pages, and the PHP interpreter is loaded each time a PHP page is called - FastCGI : apparently, the interpreter is loaded at boot time; the application itself might also be compiled and loaded once - mod_php : same as FastCGI? - application server : the application is compiled and loaded once; the application can either have its own web server, or use a web server as front end, and only handle its own part Any tips much appreciated, thank you. Each of the SAPIs operate in different environments (though I suppose CGI and FastCGI are going to nearly be swappable). CGI - As you rightly say, is loaded on a per-request basis. There is an overhead for every request to get PHP up and running prior to processing the PHP script. Fast-CGI - This requires some cooperation from the server. The server will create a set of PHP instances (separate executable, not running in the same memory space as the server) ready to receive the script. This reduces the overhead that exists with CGI from request loading to server startup/loading. mod_php - I'm on Windows and have not used Apache. But I have used ISAPI. I believe these operate in a similar fashion. In this instance, the PHP interpreter is loaded as a module of the server, just like any other module the server loads. Each PHP script is handled by a separate PHP thread. These threads are NOT separate instances of PHP, and are running within the same address space as the web server. As a consequence, several features/issues exist. Chiefly for me was the persistent database connections. As the same module of code is running all the scripts, a script can (by the use of the appropriate functions) get the database connection remembered between each script. This allows faster connection to the DB for each script. There are issues though. The connection is to the SERVER and not to the DB. The remembered connection is based upon the server, the username and password. If you use multiple databases on the same connection AND use the selectDB functionality, the single remembered DB connection will change DB. If this happens midscript, you could end up in a very strange place. But, if you use qualified naming (database_name.owner.table_name for an MS SQL example), then you will be fine. Just remember select DB is just a shortcut for the connection to use. It isn't part of the connection. Application Server - Don't know. You also have ... CLI - Command line PHP scripting. You must manually invoke PHP with the script name for it to run, though Windows has some useful features to allow you to run a PHP script without having to declare the PHP executable every time. I think the #! line is the Unix equivalent of this feature, but isn't as complete as the Windows mechanism (IMHO) - See http://docs.php.net/manual/en/install.windows.commandline.php for additional details on this. And as of 5.4, there is CLI Server. This is using PHP to run as a listener on the HTTP port and passes requests to a simple, userland, PHP-based routing script which will allow you to respond to PHP requests. See http://docs.php.net/manual/en/features.commandline.webserver.php for more details. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newline and return issues in string
On 11 October 2011 12:58, ad...@buskirkgraphics.com wrote: I have come across an issue with my string that I would like to find a faster way to resolve. It seems there are new lines and returns at different positions of the string. First I exploded on the new line explode(“\n”, $ string) This gave me a nice array but when I try to implode I get the new lines again. There is not a consistent position and there seems to be some hidden returns in the array as well. Is there a way, or has someone written a filter that would allow me to remove all the newlines and returns from the array or string. Understand I have resolved this issue but I think I have to be going about this the hard way because it is just too complex . FYI $filter = array(\r\n, \n, \r); str_replace($filter,’’,$string) ß this is useless in this situation I have tried and it does not change the string at all. You don't want to remove them. You want to replace them with a constant. $lines = explode(PHP_EOL, str_replace($filter, PHP_EOL, $string)); for example. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Namespaced code with SabreDAV
On 6 October 2011 15:37, Andrew Mason slackma...@gmail.com wrote: Hello all, I am trying to use the wonderful SabreDAV library to create a webdav share. I have a demo up and running however the framework / class i'm using is namespaced, and SabreDAV unfortunately does not have a 5.3 style namespace declaration. I have an spl_autoload function registered in my base controller and so long as I prefix the classname with a \ it all works: $rootDirectory = new \Sabre_DAV_FS_Directory($rootDir); // The server object is responsible for making sense out of the WebDAV protocol $server = new \Sabre_DAV_Server($rootDirectory); However, SabreDAV it's self has a large amount of other PHP classes which it calls which obviously aren't prefixed with '\' Is there a way i can tell PHP any class name that get's instanciated with 'Sabre_' should resolve to '\Sabre' ? Many thanks Andrew I've just downloaded SabreDav 1.5.3 Put Sabre directory in my include path. And using the following code, ... ?php namespace GoingToBeUsingSabre; require_once 'Sabre/autoload.php'; var_dump(new \Sabre_DAV_FS_Directory('D:/')); print_r(array_filter(get_declared_classes(), function($class){ return 'Sabre_' === substr($class, 0, 6);})); print_r(get_included_files()); ? outputs ... object(Sabre_DAV_FS_Directory)#1 (1) { [path:protected]= string(3) D:/ } Array ( [166] = Sabre_DAV_FS_Node [167] = Sabre_DAV_FS_Directory ) Array ( [0] = Z:\UsingSabre.php [1] = D:\PHP\Includes\Sabre\autoload.php [2] = D:\PHP\Includes\Sabre\DAV\FS\Directory.php [3] = D:\PHP\Includes\Sabre\DAV\FS\Node.php [4] = D:\PHP\Includes\Sabre\DAV\INode.php [5] = D:\PHP\Includes\Sabre\DAV\ICollection.php [6] = D:\PHP\Includes\Sabre\DAV\IQuota.php ) They provide their own autoloader. As you can see, I've included their autoloader and made 1 call to a root namespaced class. The registered autoloader took care of the rest and loaded the additional classes as needed. Take a look at the Zend Framework's autoloader (http://framework.zend.com/manual/en/zend.loader.autoloader.html) Here is the same working example, but using ZF's autoloader ... ?php namespace GoingToBeUsingSabre; require_once 'Zend/Loader/Autoloader.php'; $o_ZendLoaderAutoLoader = \Zend_Loader_Autoloader::getInstance(); $o_ZendLoaderAutoLoader-registerNamespace('Sabre_'); var_dump(new \Sabre_DAV_FS_Directory('D:/')); print_r(array_filter(get_declared_classes(), function($class){ return 'Sabre_' === substr($class, 0, 6);})); print_r(get_included_files()); ? output now is ... object(Sabre_DAV_FS_Directory)#2 (1) { [path:protected]= string(3) D:/ } Array ( [168] = Sabre_DAV_FS_Node [169] = Sabre_DAV_FS_Directory ) Array ( [0] = Z:\UsingSabre.php [1] = D:\PHP\Includes\Zend\Loader\Autoloader.php [2] = D:\PHP\Includes\Zend\Loader.php [3] = D:\PHP\Includes\Sabre\DAV\FS\Directory.php [4] = D:\PHP\Includes\Sabre\DAV\FS\Node.php [5] = D:\PHP\Includes\Sabre\DAV\INode.php [6] = D:\PHP\Includes\Sabre\DAV\ICollection.php [7] = D:\PHP\Includes\Sabre\DAV\IQuota.php ) Regards, Richard. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php on my pc, no go, FUBAR, thank you Bill Gates?
On 4 October 2011 14:47, Kirk Bailey kbai...@howlermonkey.net wrote: I installed it in a Windows XP PC with a cgi capable server in it. No dice, nothing happens. I also installed python in the same computer. Works perfect. NEITHER language modified the http server. So, what do I have to do to get php to play well with others in a XP environment? Cute remarks about install Linux shall be ignored as line-noise. If install Linux is going to be ignored as line-noise, what about RTFM? Starting at http://docs.php.net/manual/en/install.windows.php and choosing your particular web server. I would also pay attention to manual installation (http://docs.php.net/manual/en/install.windows.manual.php) and command line working (http://docs.php.net/manual/en/install.windows.commandline.php). -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php.ini setting
On 3 October 2011 14:30, Jim Giner jim.gi...@albanyhandball.com wrote: Thanks for the code sample - a little more complex than I've ever used. Can you explain something for me? The first unset line - what is it doing? If it is removing the item from the $process array, then how can you then reference the value ($v) in the very next line? I must be missing something. Also - I don't see the need to be stripping slashes from the $k (keys/indices?) elements. What am I missing there? As I said - the lines are a something new to me and I may not be interpreting what is going on here. Basically I see that you are processing all of the arrays (GET,POST, etc) at once, doing each one in turn. For each one, you then get down to the values returned to the script as a $k/$v pair which you then check to see if it is in itself an array.(although you ask if $v is an array, while I would have thought you'd ask if $k was an array). Once you get to the basest element you remove the slashes. Thanks again - still waiting on my host company to get back to me - they've escalated the problem of not being able to turn the quotes off. Hmmm ?php // Are magic quotes enabled? if (get_magic_quotes_gpc()) { // Create an array of refererences to the GET, POST, COOKIE and REQUEST super-globals. // Because these are references, any changes made to $process will also be reflected // in the GET, POST, COOKIE and REQUEST super-globals. $process = array($_GET, $_POST, $_COOKIE, $_REQUEST); // Iterate each element in $process, creating $key and $val // $key is the index of $process and $val is the referenced super-global array. while (list($key, $val) = each($process)) { // Iterate $val (the super global array), creating $k and $v // $k is the name of the entry in the super-global and $v is the value. foreach ($val as $k = $v) { // Remove the entry from the super-global. unset($process[$key][$k]); // Is the value an array. if (is_array($v)) { // Insert the value back into the super-global, but strip slashes from the key. $process[$key][stripslashes($k)] = $v; // Because the value is an array, we don't want to process it here. // Instead, append a reference to the value to the $process array. // It will be picked up after the other super-globals are processed by the while() line. $process[] = $process[$key][stripslashes($k)]; } else { // As the value is not an array, insert the stripped value back into the super-global, // using a stripped key. $process[$key][stripslashes($k)] = stripslashes($v); } } } // All done, so remove $process also. unset($process); } ? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting meta data (of any type) for an XML file being from it's URL.
On 29 September 2011 23:34, Tommy Pham tommy...@gmail.com wrote: On Thu, Sep 29, 2011 at 3:27 PM, Tommy Pham tommy...@gmail.com wrote: On Thu, Sep 29, 2011 at 9:09 AM, Richard Quadling rquadl...@gmail.com wrote: Hi. I'm looking to process very large XML files without the need of first downloading them. To that end, SimpleXMLIterator('compress.zlib://http://www.site.com/products.xml.gz') is working perfectly. But a downside is that I have no information of my progress. Is there any mechanism available to get a position within the XML stream? I can use libxml_set_streams_context() to set a context (so I can provide POST data if needed for the HTTP request), but I can't see how to gain access to the stream within the libxml code (SimpleXML uses libxml). At the most basic, what I'm looking for is to be able to record a percentage complete. Even with compression, I'll be reading some bytes from a stream (either from http or from compress.zlib) and I want to know where I am in that stream. The HTTP header will tell me how big the file is (so that can easily be a HEAD request to get that data). Even if I DO save the file locally first, I still can't get a position. If I use the SimpleXMLIterator::count() method, I am unsure as to what will happen if I am using a stream (rather than a local file). If I use ... $xml = new SimpleXMLIterator(...); $items = $xml-count(); foreach($xml as $s_Tag = $o_Item) { ... } will the XML file be cached somewhere? Or will that depend upon the originating server supporting some sort of rewind/chunk mechanism? Any suggestions/ideas? Richard. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea Richard, Only think I can think of is break up into 2 parts. 1st part use cURL for the down streams and monitor it's progress. 2nd part is XML parsing. If you want to do both simultaneously and only if the remote supports chunked encoding/transfer, you could use multiple handles of cURL into numerical indexed array variable containing the chunks for XML parsing. This could be memory intensive if the file is very large, depending whether you free the elements in the array as you progress. So if memory consumption is a major concern, you may want to save to the file locally until the import/migration is done as there maybe a situation where you'll need to review the data and, thus, saving the time and bandwidth of having to re-download the data. Regards, Tommy An afterthought, handling streams and parsing at the same may require sophisticated XML node validations as the node maybe split between the transferred chunks. The SimpleXMLIterator() does do a superb job of providing 1 node at a time and doesn't remember each node automatically. If I do, then that's my issue. Accessing the stream/file meta data doesn't seem possible. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Input variable from form help request
On 29 September 2011 23:28, PHProg php...@speedemessenger.com wrote: Hello Richard, Your suggestion worked perfectly. ... it works beautifully. Now that's what I like to hear! Glad to be of help. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [Friday] Tokyo / Kyoto.
Tokyo means Eastern Capital Kyoto means Western Capital -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS Feed Accented Characters
On 30 September 2011 17:41, Jen Rasmussen j...@cetaceasound.com wrote: Would this work? $content = El Versiacute;culo del Diacute;a; $rss_content .= description . $content . /description\r\n; Cheers! Jen The entities are HTML entities. They are not XML entities. If they are displayed as ? then it is an encoding issue. What encoding are you using? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS Feed Accented Characters
On 30 September 2011 18:22, Ron Piggott ron@actsministries.org wrote: -Original Message- From: Richard Quadling Sent: Friday, September 30, 2011 12:31 PM To: Ron Piggott Cc: php-general@lists.php.net Subject: Re: [PHP] RSS Feed Accented Characters On 30 September 2011 17:26, Ron Piggott ron@actsministries.org wrote: I am trying to set up an RSS Feed in the Spanish language using a PHP cron job. I am unsure of how to deal with accented letters. An example: This syntax: ?php $rss_content .= description . htmlentities(El Versículo del Día) . /description\r\n; ? Outputs: descriptionEl Versiacute;culo del Diacute;a/description When I use an RSS Feed validator I receive the error message This feed does not validate. a.. line 24, column 20: XML parsing error: unknown:24:20: undefined entity I suspect the “;” is the issue, although it is needed for the accented letters. If I don’t use htmlentities() the accented characters can’t be viewed, they become a “?” How should I proceed? Ron Make sure you have ... ?xml version=1.0 encode=UTF-8? as the first line of the output. That tells the reader that the file is a UTF-8 encoded file. Also, if you ejecting HTTP headers, make sure that they say the encoding is UTF-8 and not a codepage. Go UTF-8 everywhere. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea Hi Richard: Having ?xml version=1.0 encoding=UTF-8? as the starting line didn't correct the problem. The RSS Feed is @ http://www.elversiculodeldia.info/peticiones-de-rezo-rss.xml There are a variety of errors related to accented characters while using a feed valuator http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fwww.elversiculodeldia.info%2Fpeticiones-de-rezo-rss.xml - Also While viewing the feed in Firefox once the first accented character is displayed none of the rest of the feed is visible, except by right clicking and view source The RSS Feed content will be populated by a database query. The database columns are set to utf8_unicode_ci How should I proceed? Ron The byte sequence that is being received is just 0xED. php -r file_put_contents('a.rss', file_get_contents('http://www.elversiculodeldia.info/peticiones-de-rezo-rss.xml')); This is NOT UTF-8 encoded data, but is ISO-8859-1 Latin-1 (most likely). So as I see it you have 1 choice. Either use ?xml version=1.0 encoding=ISO-8859-1? as the XML tag or convert the encoded data to UTF-8. It also means that the data in the sql server is NOT UTF-8 and will need to be converted also. I would recommend doing that first. That will mean reading the data as ISO-8859-1 and converting it to UTF-8 and then saving it again. I'd also be looking at the app that inputs the data into the DB initially. To convert the text, here are 2 examples. I'm sure there are more ways. ?php $iso_text = 'El Versículo del Día: Pray For Others: Incoming Prayer Requests'; $utf_8_text = utf8_encode($iso_text); var_dump($iso_text, $utf_8_text); $utf_8_text = iconv('ISO-8859-1', 'UTF-8', $iso_text); var_dump($iso_text, $utf_8_text); ? outputs ... string(63) El Vers퀀culo del D퀀a: Pray For Others: Incoming Prayer Requests string(65) El Versículo del Día: Pray For Others: Incoming Prayer Requests string(63) El Vers퀀culo del D퀀a: Pray For Others: Incoming Prayer Requests string(65) El Versículo del Día: Pray For Others: Incoming Prayer Requests notice that the correct strings are 2 bytes longer? The í is encoded as 0xC3AD or U+00ED. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Input variable from form help request
On 29 September 2011 13:30, PHProg php...@speedemessenger.com wrote: ?php if(!@copy('http://mydomain.com/files/ .$_POST['trakname'].','/.$_POST['dirname']./.$_POST['trakname'].')) { $errors= error_get_last(); echo COPY ERROR: .$errors['type']; echo br /\n.$errors['message']; } else { echo File copied from remote!; } ? Try ... ?php if(!@copy(http://mydomain.com/files/{$_POST['trakname']}, /{$_POST['dirname']}/{$_POST['trakname']})) { $errors= error_get_last(); echo 'COPY ERROR: ', $errors['type'], 'br /', PHP_EOL, $errors['message']; } else { echo 'File copied from remote!'; } ? You need to keep track of the opening and closing quotes (single and double). In the copy() function, I'm using the embedded variable method (a string using double quotes will evaluate the variables at run time). In the echo statements, I'm not using concatenation as, theoretically, it should be faster as the echo statement will not need to first build the concatenated string before echoing it. It will just push the values out the to the web server. I think. I've not done any metric testing on that. As for copying a file TO a http URL, you need to obey the rules of http. CURL or FTP will be the protocols of choice here, though you do have the option of using a stream context to wrap the file_put_contents() into a POST form to the site (similar to CURL in some ways). -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Getting meta data (of any type) for an XML file being from it's URL.
Hi. I'm looking to process very large XML files without the need of first downloading them. To that end, SimpleXMLIterator('compress.zlib://http://www.site.com/products.xml.gz') is working perfectly. But a downside is that I have no information of my progress. Is there any mechanism available to get a position within the XML stream? I can use libxml_set_streams_context() to set a context (so I can provide POST data if needed for the HTTP request), but I can't see how to gain access to the stream within the libxml code (SimpleXML uses libxml). At the most basic, what I'm looking for is to be able to record a percentage complete. Even with compression, I'll be reading some bytes from a stream (either from http or from compress.zlib) and I want to know where I am in that stream. The HTTP header will tell me how big the file is (so that can easily be a HEAD request to get that data). Even if I DO save the file locally first, I still can't get a position. If I use the SimpleXMLIterator::count() method, I am unsure as to what will happen if I am using a stream (rather than a local file). If I use ... $xml = new SimpleXMLIterator(...); $items = $xml-count(); foreach($xml as $s_Tag = $o_Item) { ... } will the XML file be cached somewhere? Or will that depend upon the originating server supporting some sort of rewind/chunk mechanism? Any suggestions/ideas? Richard. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sequential access of XML nodes.
On 27 September 2011 03:38, Ross McKay ro...@zeta.org.au wrote: On Mon, 26 Sep 2011 14:17:43 -0400, Adam Richardson wrote: I believe the XMLReader allows you to pull node by node, and it's really easy to work with: http://www.php.net/manual/en/intro.xmlreader.php In terms of dealing with various forms of compression, I believe you con use the compression streams to handle this: http://stackoverflow.com/questions/1190906/php-open-gzipped-xml http://us3.php.net/manual/en/wrappers.compression.php +1 here. XMLReader is easy and fast, and will do the job you want albeit without the nice foreach(...) loop Richard spec's. You just loop over reading the XML and checking the node type, watching the state of your stream to see how to handle each iteration. e.g. (assuming $xml is an open XMLReader, $db is PDO in example) $text = ''; $haveRecord = FALSE; $records = 0; // prepare insert statement $sql = ' insert into Product (ID, Product, ...) values (:ID, :Product, ...) '; $cmd = $db-prepare($sql); // set list of allowable fields and their parameter type $fields = array( 'ID' = PDO::PARAM_INT, 'Product' = PDO::PARAM_STR, ... ); while ($xml-read()) { switch ($xml-nodeType) { case XMLReader::ELEMENT: if ($xml-name === 'Product') { // start of Product element, // reset command parameters to empty foreach ($fields as $name = $type) { $cmd-bindValue(:$name, NULL, PDO::PARAM_NULL); } $haveRecord = TRUE; } $text = ''; break; case XMLReader::END_ELEMENT: if ($xml-name === 'Product') { // end of Product element, save record if ($haveRecord) { $result = $cmd-execute(); $records++; } $haveRecord = FALSE; } elseif ($haveRecord) { // still inside a Product element, // record field value and move on $name = $xml-name; if (array_key_exists($name, $fields)) { $cmd-bindValue(:$name, $text, $fields[$name]); } } $text = ''; break; case XMLReader::TEXT: case XMLReader::CDATA: // record value (or part value) of text or cdata node $text .= $xml-value; break; default: break; } } return $records; Thanks for all of that. It seems that the SimpleXMLIterator is perfect for me. I need to see if the documents I'm needing to process have multiple namespaces. If they have do, then I'm not exactly sure what to do at this stage. Richard. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sequential access of XML nodes.
Hi. I've got a project which will be needing to iterate some very large XML files (around 250 files ranging in size from around 50MB to several hundred MB - 2 of them are in excess of 500MB). The XML files have a root node and then a collection of products. In total, in all the files, there are going to be several million product details. Each XML feed will have a different structure as it relates to a different source of data. I plan to have an abstract reader class with the concrete classes being extensions of this, each covering the specifics of the format being received and has the ability to return a standardised view of the data for importing into mysql and eventually MongoDB. I want to use an XML iterator so that I can say something along the lines of ... 1 - Instantiate the XML iterator with the XML's URL. 2 - Iterate the XML getting back one node at a time without keeping all the nodes in memory. e.g. ?php $o_XML = new SomeExtendedXMLReader('http://www.site.com/data.xml'); foreach($o_XML as $o_Product) { // Process product. } Add to this that some of the xml feeds come .gz, I want to be able to stream the XML out of the .gz file without having to extract the entire file first. I've not got access to the XML feeds yet (they are coming from the various affiliate networks around, and I'm a remote user so need to get credentials and the like). If you have any pointers on the capabilities of the various XML reader classes, based upon this scenario, then I'd be very grateful. In this instance, the memory limitation is important. The current code is string based and whilst it works, you can imagine the complexity of it. The structure of each product internally will be different, but I will be happy to get back a nested array or an XML fragment, as long as the iterator is only holding onto 1 array/fragment at a time and not caching the massive number of products per file. Thanks. Richard. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any free online tests to test my PHP knowledge?
On 22 September 2011 18:53, Mike Hansen skrab...@comcast.net wrote: Does anyone know of a site that has an online test of PHP skills? I'd like to review my PHP knowledge. I've already run across this site: http://vladalexa.com/scripts/php/test/test_php_skill.html Thanks, Mike I took the ZCE exam and I used The Zend PHP Certification Practice Test Book and the Zend PHP Certification Study Guide. Both of these are for PHP4 (though I never actually used PHP4) - so no good now - unless you use PHP4 of course. There is a PHP 5 Study Guide (http://www.phparch.com/books/phparchitects-zend-php-5-certification-study-guide-2nd-edition/) I have the first edition, so a little out of date now but I do get a free PDF of the 2nd edition. Richard. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP installations, usage, and popularity
On 19 September 2011 22:08, Tedd Sperling tedd.sperl...@gmail.com wrote: Hi gang: I need information to convince administrators in management that PHP is a viable subject that should be taught in college with credits going toward a Degree or Certification. You see, I am pushing for a Web Development Certification program that would include PHP/MySQL as well as several other Web Languages (i.e., html, css, javascript, ajax). Currently the college teaches ASP in a regular course toward a IT Certification, but class attendance has dropped considerably -- no one wants to take the course. However, My PHP class has been maxed out. But my class is a special topic class and not part of the regular coursework that would go towards a Degree or Certification -- and that's where I would like this to go. As such, I need information regarding how wide-spread PHP is (i.e., number of installations), who's using it (i.e., companies, organizations), and how it compares with other Web Languages (i.e., ASP, Ruby, etc.). So, what say you? References will work. Thanks, tedd Considering this is academia, how about WikiPedia? http://en.wikipedia.org/wiki/MediaWiki 75 languages and over 3.5 million pages : http://en.wikipedia.org/wiki/Special:Statistics So, this is just 1 site. Of course, you can easily have a Flash frontend with a PHP backend. The whole nature of PHP is that it can fit anywhere. Web, Console, GUI (with appropriate bindings). Multii-platform, architecture, OS, etc. - probably preaching to the converted here. I would also recommend the inclusion of a nosql module and MAYBE some Windows specific elements (I use IIS/MSSQL/PHP no problem. MS SQL driver for PHP is PDO and works very nicely). -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Round with money_format
On 17 September 2011 15:56, Bill Guion bgu...@comcast.net wrote: On Sep 17, 2011, at 3:46 AM, Cyril Lopez wrote: From: Cyril Lopez cy...@nethik.fr Date: September 16, 2011 10:58:28 AM EDT To: php-general@lists.php.net Subject: Round with money_format Hi, Can someone help me understand how money_format() rounds numbers ? ?php setlocale(LC_ALL, 'fr_FR.UTF-8'); $price = 12.665; echo money_format('%i',$price); // 12.66 EUR, 12.67 EUR expected $price2 = 12.666; echo money_format('%i',$price2); // 12.67 EUR, ok echo round($price,2); // 12.67, ok echo round($price2,2); // 12.67, ok ? Misconfiguration ? Bug ? Thanks ! Cyril Config : Debian Lenny, PHP 5.3.8 As someone else pointed out, rounding rules vary by locale, but I was taught 40+ years ago in graduate school programming class, 4 rounds down, 6 rounds up, and 5 rounds to the even number. This means 65 rounds to 6, while 75 rounds to 8. Your example seems to follow that rule. I've been looking to see if I can find the locale's rounding rules - I can't. Would be useful if anyone knows where they are defined. As far as I can find (pages similar to http://www.cl.cam.ac.uk/cgi-bin/manpage?7+locale), the locale data doesn't seem to include the rounding rules. Sure, the number of DP, grouping, etc. Yes. But no rounding. So, does this just truncate? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML enabled but not working
On 15 September 2011 21:20, Matthew Pounsett m...@conundrum.com wrote: Anyone have any thoughts on what to look at? php -m look for XML php --rf xml_parser_create look for Function [ internal:xml function xml_parser_create ] { - Parameters [1] { Parameter #0 [ optional $encoding ] } } -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Round with money_format
On 16 September 2011 15:58, Cyril Lopez cy...@nethik.fr wrote: Hi, Can someone help me understand how money_format() rounds numbers ? ?php setlocale(LC_ALL, 'fr_FR.UTF-8'); $price = 12.665; echo money_format('%i',$price); // 12.66 EUR, 12.67 EUR expected $price2 = 12.666; echo money_format('%i',$price2); // 12.67 EUR, ok echo round($price,2); // 12.67, ok echo round($price2,2); // 12.67, ok ? Misconfiguration ? Bug ? Thanks ! Cyril Each locale can define its own rules regarding the number of digits to show, but I can't see anything that covers the rounding. OOI. What do you get for 12.66999? I'm on windows and there's no money_format function (due to a lack of strfmon() function), -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML enabled but not working
On 16 September 2011 23:18, Matthew Pounsett m...@conundrum.com wrote: On 2011/09/16, at 10:27, Richard Quadling wrote: On 15 September 2011 21:20, Matthew Pounsett m...@conundrum.com wrote: Anyone have any thoughts on what to look at? php -m php --rf xml_parser_create Thanks. This seems to reinforce that there's something wrong, but I don't feel like I know any more about what's broken. :) php -m [PHP Modules] Core date ereg libxml mysqlnd pcre Reflection SPL standard [Zend Modules] php --rf xml_parser_create Exception: Function xml_parser_create() does not exist The xml_parser_create() function is in the XML extension, not in the libxml extension. php --re libxml vs php -d extension=php_xml.dll --re xml Assuming php_xml.dll is available (may need to be .so rather than .dll for non windows). -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] lost return value during a static call
On 15 September 2011 14:01, chamila gayan cgcham...@gmail.com wrote: hi All, I'm seeing a weired behavior in following code http://pastebin.com/B5q8i1RY when it goes through 2 static methods, at some point it stops returning value to the calling method. (please see comments in-line). may be I'm doing this in a wrong way so your suggestions are welcome. And I really appreciate if someone can explain how 'return' behaves with static methods specially when they are called recursively. thanks a bunch chamila New pastie http://pastebin.com/AnZ1r7yR Output is ... Z:\ppp.php 108parentclass::getChild 29parentclass::getChild 40parentclass::getArray 22parentclass::getChild 29parentclass::getChild 32parentclass::childload 6parentclass::childload 9childA::__construct 54childA::setA 67childA::setA 69childA::__construct 56parentclass::getChild 34childA Object( [a:childA:private] = 1)parentclass::getArray 24parentclass::getChild 42parentclass::getChild 44Z:\ppp.php 110Z:\ppp.php 112 Using PHP 5.3.9-dev on Win32. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What would you like to see in most in a text editor?
On 14 September 2011 01:23, tamouse mailing lists tamouse.li...@gmail.com wrote: On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings rob...@interjinn.com wrote: I'm a big fan of editors that work in the terminal. You'll get my emacs when you pry it out of my cold dead hands. Pah! You and your full screen editor. EDLIN is the way to go. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] What would you like to see in most in a text editor?
On 14 September 2011 13:18, Tim Streater t...@clothears.org.uk wrote: On 14 Sep 2011 at 12:40, Richard Quadling rquadl...@gmail.com wrote: On 14 September 2011 01:23, tamouse mailing lists tamouse.li...@gmail.com wrote: On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings rob...@interjinn.com wrote: I'm a big fan of editors that work in the terminal. You'll get my emacs when you pry it out of my cold dead hands. Pah! You and your full screen editor. EDLIN is the way to go. Is that more or less terse than TECO? Back in 1989 when I was at SLAC, they were just getting into unix, and debates were raging about which editor to standardise on and teach people (emacs, vi, jove, etc). Because this wasn't settled, I started using notepad (and later, dxnotepad) and got on with coding. Six months later, the debates were still raging. I then had an epiphany: I'd been using notepad for six moths got work done. It took me 5 minutes to find out how to use it. I didn't need teaching about it or to have a manual. So IMO, emacs, vi, and all their ilk belong in the dustbin of history. -- Cheers -- Tim TECO - OUCH. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dereferencing an array.
Hi. Based upon ... ?php $name = Null; $age = Null; $boundParams = array('name' = $name, 'age' = $age); $records = array(); $name = 'Richard'; $age = 43; $records[] = $boundParams; $name = 'Sally'; $age = 37; $records[] = $boundParams; print_r($records); ? outputs Sally twice. Whilst that is the correct output based upon the code, it is undesired. I want the boundParams to have the references (the actual data from my mysqli_stmt::fetch() with bound results), but I want to be able to copy the values and not maintain the references. The best I've come up with is ... ?php $name = Null; $age = Null; $boundParams = array('name' = $name, 'age' = $age); $records = array(); $columns = array_keys($boundParams); $name = 'Richard'; $age = 43; //$records[] = $boundParams; $records[] = array_combine($columns, array_map(function($m_Value){return $m_Value;}, $boundParams)); $name = 'Sally'; $age = 37; //$records[] = $boundParams; $records[] = array_combine($columns, array_map(function($m_Value){return $m_Value;}, $boundParams)); print_r($records); ? Is there a more efficient way? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sessions expiring early
On 7 September 2011 11:20, Paul Waring p...@phpdeveloper.org.uk wrote: I'm having trouble with a PHP website which requires users to be logged in to access all content other than the home page and a couple of static pages (about us, contact us etc.). Several users have said they are being logged out every few minutes whilst using the site - they can login but will be shown the login form again after a few minutes. I can't confirm this myself as the site seems to work fine for me - even using the same browser as they are and under their accounts - but I'm wondering if this could be a problem with the session settings? The current settings I have are: session.auto_start Off session.bug_compat_42 On session.bug_compat_warn On session.cache_expire 180 session.cache_limiter nocache session.cookie_domain no value session.cookie_httponly Off session.cookie_lifetime 0 session.cookie_path / session.cookie_secure Off session.entropy_file no value session.entropy_length 0 session.gc_divisor 100 session.gc_maxlifetime 3600 session.gc_probability 1 session.hash_bits_per_character 4 session.hash_function 0 session.name PHPSESSID session.referer_check no value session.save_handler files session.save_path /shared/sessions session.serialize_handler php session.use_cookies On session.use_only_cookies Off session.use_trans_sid 0 The only options I have changed from the defaults are gc_maxlifetime, gc_probability and save_path. There are several sites on the same server, some are https, others just plain http. They all use the same session options. session_start() is called once on every page. The PHP version we're running is: PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 1 2011 16:01:01). I'm aware it's an old version before anyone tells me to upgrade (it's the latest stable version in Debian Lenny). :) Potential problems I have already ruled out: 1. I don't think it's a browser problem as the users have a variety of browsers and versions (we log the user agent for each login, they're mostly IE7/8 on XP/Vista/7 with a few Chrome users), and I can't reproduce the problem using the same browsers on my machine. 2. The server time is correct. 3. The sessions aren't stored in a directory which is being regularly cleared out, such as /var/lib/php5 or /tmp. 4. The web server has permission to write to the save_path directory, and I can see session files being created. 5. No output buffering functions are being used. Can anyone suggest things which I could try? I cannot work out why this problem is happening for some users but not me. Thanks in advance. Paul How do you handle multiple logins? If I login using my laptop and get Session A for my account and then I login using my desktop and get Session B for my account, does Session A get killed? Do you allow multiple, simultaneous logins per account? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sessions expiring early
On 7 September 2011 11:20, Paul Waring p...@phpdeveloper.org.uk wrote: Can anyone suggest things which I could try? I cannot work out why this problem is happening for some users but not me. For browsers/extensions that do automatic read ahead (I load page A and linked pages B and C are also retrieved). Is the potential for cached pages to be returned for a user NOT logged in? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code should be selv-maintaining!
On 30 August 2011 23:25, Richard Quadling rquadl...@gmail.com wrote: On 30 August 2011 20:09, Robert Cummings rob...@interjinn.com wrote: You're just saying that so Tedd will be your friend!! Come now, let's be honest with everyone... Whitesmith's is -GLEE! ;) Beauty is in the eye of the beholder. So I think we've all established that Whitesmith's is the way to go, but what about markup languages? Take our own lovely PHPDocumentation. Here, in the main, we have all subordinate elements starting on their own line, indented. Is there really any other way that would make sense? -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP/ Soap issue
I am hoping there's a SOAP expert on the list as this is driving me mad and Google doesn't come up with much help ... I am trying to build a fairly simple web service in SOAP -- the client sends a string SKU to query a product catalogue database and receives product pricing data - I am using a WSDL file which validates OK ... anyway I keep getting this error:- SOAP-ERROR: Encoding: object has no 'name' property The PHP code is below:- $client = new SoapClient('http://example.com/catalogue.wsdl',array('trace' = 1,'exceptions' = 0)); $sku = '12345'; $client-getProduct($sku); I can post the wsdl file contents if necessary. Hoping someone can help point me in the right direction! TIA Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/ Soap issue
On 01/09/2011 14:07, Louis Huppenbauer wrote: I think it would be best if you could provide us with the .wsdl (and possibly with the server-code). Thanks for the quick response Louis.. WSDL ?xml version=1.0 encoding=UTF-8? definitions name=CatalogueService targetNamespace=http://example.com/catalogue.wsdl; xmlns=http://schemas.xmlsoap.org/wsdl/; xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/; xmlns:tns=http://example.com/catalogue.wsdl; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:xsd1=http://example.com/schema; types xsd:schema targetNamespace=http://example.com/schema; xmlns=http://www.w3.org/2001/XMLSchema; xsd:complexType name=product xsd:sequence xsd:element name=name type=xsd:string/ xsd:element name=description type=xsd:string/ xsd:element name=price type=xsd:double/ xsd:element name=SKU type=xsd:string/ /xsd:sequence /xsd:complexType /xsd:schema /types message name=getProductRequest part name=sku type=xsd:string/ /message message name=getProductResponse part name=product type=xsd1:product/ /message portType name=Product_PortType operation name=getProduct input message=tns:getProductRequest/ output message=tns:getProductResponse/ /operation /portType binding name=Product_Binding type=tns:Product_PortType soap:binding style=rpc transport=http://schemas.xmlsoap.org/soap/http/ operation name=getProduct soap:operation soapAction=urn:examples:CatalogueService/ input soap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; namespace=urn:examples:CatalogueService use=encoded/ /input output soap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; namespace=urn:examples:CatalogueService use=encoded/ /output /operation /binding service name=Product_Service port name=Product_Port binding=tns:Product_Binding soap:address location=http://example.com/api/catalogue/ /port /service /definitions SERVER CODE ini_set('soap.wsdl_cache_enabled',false); $server = new SoapServer('http://example.com/catalogue.wsdl'); $server-handle();
Re: [PHP] PHP/ Soap issue
On 01/09/2011 14:16, Richard Quadling wrote: Can you give me the URL for the WSDL file? Either online or by direct email. Thanks for the quick response Richard -- I have just posted the WSDL in my earlier resply to Louis... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php