I've encountered the oddest thing today and I'm not sure what to make of it.
Here's my code:
<?php
$nf = new \NumberFormatter("en_UK", \NumberFormatter::ORDINAL);
die(var_dump($nf->format(1)));
This code outputs the following in PHP version 5.6.20:
string(3) "1st"
but it outputs the following in PHP version 5.6.14:
string(6) "1ˢᵗ"
I'm not sure what to make of this. The superscripted version is something I was not expecting. I went through the change logs but haven't seen this change documented. Anyone know if this is intended behaviour? Any way to force it back to the first behaviour (because it looks odd when rendering it in forms)?
The PHP 5.6.20 installation is using ICU version 4.8.1.1 while 5.6.14 is using ICU version 4.4.0.1
I'd just upgrade to a newer ICU.
The strange superscript was fixed in CLDR 2.0 It was introduced in this ticket years before. I'm not sure which CLDR version introduced it, but unfortunately my name is on as the reviewer. Maybe it seemed like a good idea at the time.
This is data from CLDR and not code, usually we don't make a changelog entry for each data change.
Related
Recently I have migrated one of my projects (PHP 7.4/Lumen/Ubuntu 20.04) from MongoDB to MongoDB compatible AWS DocumentDB. Since the migration all the CLI Scripts are triggering this strange notice/warning
bson_append_array(): invalid array detected. first element of array parameter is not "0".
Everything seems to be functionally working apart from this message (Even though I have all the PHP errors hidden from ini file this still shows up). Not really sure what is going on.
Message is actually coming from "find" method. I also did try to suppress the msg but no luck.
Does anyone have any idea what is going on here ? Appreciate and thanks for all your responses in advance.
DocumentDB version 4.0
PHP SDK Composer version 1.9.0
If you add &authMechanism=SCRAM-SHA-1 to the connexion string, the warning disepear.
I am answering my own questions based on my findings so far.
Seems like there is no solution for this issue since AWS DocumentDB is not 100% compatible with MongoDB (As per mongoDb documentation over 66% of all of the correctness tests have failed for DocumentDB). Also it is extremely difficult get AWS support for these sort of incompatibility issues, they always refer you to public user forum.
MongoDB recently put up a blog post summering incompatibility issues with DocumentDB and it makes a lot of sense. You can read it in detail here - https://www.mongodb.com/atlas-vs-amazon-documentdb/compatibility
My recommendation is if you are considering using documentDB as a replacement of Mongo do not bother. Save your precious time by sticking with MongoDB.
I wish to be able to do something like:
php --determine-oldest-supported-php-version test.php
And get this output:
7.2
That is, the php binary checks test.php for all function calls or syntax used, and then spits out the oldest version of PHP which would be able to run the script.
The purpose would be for me to create a script which goes through all the .php files in my library/framework and figures out which version of PHP I should consider to be the "oldest supported version".
Currently, I'm doing this manually. Whenever I knowingly use a new feature, function or syntax, I bump up a variable to "7.4" or whatever, and then compare the currently used PHP version against that on runtime. This is not ideal, as you can imagine, and I could very well forget to bump up this value or bump it up too much, or too little, etc.
It would be much nicer to be able to determine this automatically, with such a feature in PHP itself.
I have of course looked through the list of options and PHP has no such feature as far as I can tell. Since I basically answered my own question right away, are there any plans on such a feature in the future?
The only guarantee given is that PHP will remain compatible within the same major version.
You may be interested in looking at the article
Why You Should Be Using Supported PHP Versions.
The tool you are looking for is the GitHub project
PHP_CodeSniffer,
further described in the article
PHPCompatibility update.
You may run it using a command such as:
phpcs --standard=PHPCompatibility --runtime-set testVersion 5.4 <path-of-your-php-files>
Where does PHP's NumberFormatter take the locale formats from? More interested in Linux environment, if that makes any difference.
Is it compiled in, or some system resource is used? How can I view the formats for each supported locale? (locale -c -k LC_MONETARY doesn't seem to list/have the info on the pattern.) Are they modifiable per server?
If there is a mistake in a format, where can I report it or propose a fix? (E.g., the lv_LV locale has a mistake regarding the thousand separators.)
Why is the output different for HHVM – https://3v4l.org/ms1ZN ?
PHP uses ICU library (see function unum_formatDoubleCurrency in ext/intl/formatter/formatter_format.c).
ICU library, in turn, uses Common Locale Data Repository (CLDR) (see http://userguide.icu-project.org/icudata).
The format in the example (currency format for lv_LV locale), can be seen in CLDR's Survey Tool – http://st.unicode.org/cldr-apps/v#/lv/Number_Formatting_Patterns/
If there was a bug, it could be reported at http://unicode.org/cldr/trac/newticket or edited in the Survey Tool by an account acquired in this contact form: http://www.unicode.org/reporting.html
But, in the current case, there was no bug.
The format of PHP does not match CLDR data probably because of the libicu version (and its CLDR version) that is installed on the particular computer/server, or a specific data file being used (icudatl.dat, see http://userguide.icu-project.org/icudata). At the moment (2018-09), the latest libicu/data version is 62 (see http://site.icu-project.org/home) and the latest CLDR version is 34 (see http://cldr.unicode.org/).
If icu-devtools is installed, running icuinfo would display what libicu and CLDR versions are being used. In my case: <param name="version">55.1</param>[..]<param name="cldr.version">27.0.1</param>
There are two alternatives given for the currency format in lv_LV, HHVM apparently uses the other, for some reason.
Not easy to be answered if it is not documented in the official docs. However lets have a look on the NumberFormatter implementation of PHP: https://github.com/php/php-src/tree/8939c4d96b8382abe84f35e69f4f6ebd6f0f749d/ext/intl/formatter
If you are good in C you may find the correct place I did not find it instantly (if one of us does lets replace this part of the answer).
However as far as I understand the code the correct formats are retrieved from the intl package (=internationalization package, http://php.net/manual/de/book.intl.php). NumberFormatter itself is part of it.
In case you find a real bug you can propose a fix at the official PHP Bug reporting site regarding the intl package (https://bugs.php.net/).
I was working on a couple of backwards compatibility issues and have been using the PHP manual for reference. Ive been using the version information located at the top of the page.
Example, is_null version information is
(PHP 4 >= 4.0.4, PHP 5, PHP 7)
From this I have understood that is_null exists in PHP 4 only if the version is greater than or equal 4.0.4 and it also exists in all versions of PHP 5 & PHP 7.
I have come to realise that the information might not be correct as is_dir version information is
(PHP 4, PHP 5, PHP 7)
but by doing a little googling ("is_dir" "PHP 3") I found out it was introduced in version 3.
Firstly have I understood the version information correctly? and is there another way to find when a function or pre-defined constant was added ?
Edit
The PHP 4 Change Log and the PHP 5 Change Log were helpful, they provide a detailed list of all changes and I have no reason to believe that any information is incorrect. Unfortunately there doesn't seem to be a change log for anything prior to that.
Update
Although no change logs seems to exist, the source code for all versions of PHP are available to download from http://museum.php.net/ so it is possible to determine the origin of functions,predefined constants and any other part of PHP from viewing the source.
The php.net website is not a complete historic reference, it attempts to show you what should be relevant.
At some time in the not too distant future, I imagine a lot of the PHP4 stuff will be gone, since there's no sense in talking about PHP4 in the year 2015, and room must be made for PHP7.
There is even less sense in talking about PHP3, but it so happens that you can find the PHP3 manual in PDF form with a google search, here's the top result for me.
Im trying to compile phpurple. Im doing everything according to the documentation:
hxxp://phurple.php.belsky.info/ch02.html
but "make" gives me an error:
/myhomedir/phpurple/purple.c: In function ‘call_custom_method’:
/myhomedir/phpurple/purple.c:1370: error: ‘zend_fcall_info’ has no member named ‘object_pp’
/myhomedir/phpurple/purple.c:1408: error: ‘zend_fcall_info_cache’ has no member named ‘object_pp’
I`ve found other people with the same problem:
hxxp://www.mail-archive.com/monetdb-bugs#lists.sourceforge.net/msg05515.html
hxxp://belsky.info/archives/23-Phurple-per-se-PHPurple.html
but nobody gives any information about successful php 5.3 build and the message
PROJECT IS CLOSED if you want
commercial support for php 5.3, let me
know ... )
does not help at all.
does anyone have any idea how to compile it or any clue how to fix the problem ?
P.S. Sorry about the links, some strange StackOverflow limitation
According to phpurple requirements:
Please let me know, if you've successfully compiled on
earlier versions. Actually the extension is being developed
on the php v5.2.6 with the option to be upcomming php v5.3
compatible.
The authors will need to update their source. However, since you have the source you could update it yourself because you noted that the project is CLOSED. You could also fork the code and create your own gitHub project with php 5.3 support.
Good luck.
What you are seeing is PHP's shifty interface (ahem, hold your down votes, I said s h i f t y). By that, I mean function prototypes are subject to change from version to version. Take this meta example:
int foo_call_bar(const char *foobar, size_t len);
And in a later version of something, the function calculates the length dynamically, thus eliminating the second variable in the prototype:
int foo_call_bar(const char *foobar);
Some projects strive to always maintain backwards compatibility to alleviate this headache, which could be accomplished with pre-processor directives that prototype the new implementation with the len variable, but just don't do anything with it. If PHP did that, the code base would succumb to even more madness.
Unfortunately, you'll have to modify phpurple to present the correct arguments to the correct PHP functions, and ensure that they are of the appropriate type. That would be a bit of an undertaking, but probably wouldn't be as difficult as it seems.
The Linux kernel's VFS interface is the same way, and I'm often tasked with porting older experimental file systems to work on modern kernels.
look at that man
http://sourceforge.net/news/?group_id=235197&id=296063
A little late, but here is the latest library that works with PHP 5.3:
The new project page is: http://sourceforge.net/projects/phurple
The blog post: http://belski.net/archives/23-Phurple-per-se-PHPurple.html
I have ran into a problem after I have complied it and added the extension to PHP.ini configuration:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/phurple.so' - /usr/lib/php/modules/phurple.so: undefined symbol: ZVAL_ADDREF in Unknown on line 0
To fix this, change the line containing ZVAL_ADDREF in client.c from
ZVAL_ADDREF(PHURPLE_G(phurple_client_obj));
to
Z_ADDREF_P(PHURPLE_G(phurple_client_obj));
Well, the new URL seems to be a persistent repo with fixes to PHP-5.3 and above. Maybe that should be mentioned, but that won't help with checking it out anyway. For me it worked fine, so I would say it is worth a try.
You can check the new sources shortly posted on https://github.com/weltling/phurple