php-5.3

Gettext not working, no error messages, using php 5.3

拜拜、爱过 提交于 2019-12-06 08:14:34
I've been bouncing my head in this for a couple of days now without any success. I just want to get gettext to work. What happens is that the string as it is written in the php-file is printed, not the translated one. I.e. if i do "echo gettext("Service");" then "Service" is printed, not the swedish "Tjänster". There are absolutely no error messages in httpd/error_log. Not when running the app or (re-)starting apache. Using Centos 6.2 and php 5.3. This is my directory structure: /path/to/locale/sv_SE.utf8/LC_MESSAGES/messages.mo /path/to/setlocale.php My messages.po file: msgid "" msgstr ""

Tumblr API V2 Error code 429: “Rate Limit Exceeded” You are being rate limited, slow down. Header info?

一个人想着一个人 提交于 2019-12-06 04:20:49
I tested Tumblr API with PHP, then I try to follow with friends using API and worked successfully, then later I get this error: Error 429 "Rate Limit Exceeded" I heard I need to wait 1 hour and limits will gone. Also I see a few information about headers: x_ratelimit_api_followers_limit x_ratelimit_api_followers_remaining x_ratelimit_api_followers_reset This informations can be in header. What header? Oauth? I don't found that. How can I see this variables? How can I get more information about API follower limitations? Tumblr's API documentation not contain that. Stephan Answer provided by

If condition for PHP Version ignore new code

旧时模样 提交于 2019-12-06 03:48:22
So I've got a script that needs to run on several sites. I've got one version of the script that is optimised with some new PHP 5.3 functions, however some sites are 5.2 etc. This code: if (version_compare(PHP_VERSION, '5.3.0') >= 0) { Do the optimised 5.3 code (Although 5.2 throws syntax errors for it) } else { do the slower version of code } However, on the 5.2 servers, it will detect the "syntax errors" in the first if condition, even though it technically should skip that content, I'm aware that PHP still scans the whole file. How can I get 5.2 to ignore the first if completely (I know I

unexpected cast to boolean?

梦想与她 提交于 2019-12-05 18:13:25
Given this input: http://example.com/item.php?room=248&supply_id=18823 , the following 2 blocks ought to produce the same result. Why don't they? What am I missing other than coffee? This block gives the expected values: if (isset($_GET['supply_id']) && isset($_GET['room'])) { $id=validkey($_GET['supply_id']); //18823 $room=validkey($_GET['room']); //248 $arr=array('s'=>$id,'r'=>$room); //s=>18823, r=>248 } But if I do the check and the assignment in one step, $id ends up equal to 1 instead of 18823. Why? if (isset($_GET['supply_id']) && isset($_GET['room'])) { if($id=validkey($_GET['supply_id

PHP Create Timeslots with break timing using DatePeriod

拈花ヽ惹草 提交于 2019-12-05 18:01:00
I want to create time slots with start,end time & also break timing. public function getServiceScheduleSlots($duration,$break, $stTime,$enTime) { $start = new DateTime($stTime); $end = new DateTime($enTime); $interval = new DateInterval("PT" . $duration. "M"); $period = new DatePeriod($start, $duration, $end); foreach ($period as $dt) { $periods[] = $dt->format('H:iA'); } return $periods; } For ex., My service start time 10:00 AM , End Time 12:00 PM . Condition: each service time 30 min & 15 min break. Above method returns like, 10:00 AM - 10:30 AM 10:30 AM - 11:00 AM 11:00 AM - 11:30 AM 11:30

How to access the property/ value of an array which has been converted into an object?

可紊 提交于 2019-12-05 10:28:52
How can I access the property/ value of an array which has been converted into an object? For instance, I want to access the value in the index 0, $obj = (object) array('qualitypoint', 'technologies', 'India'); var_dump($obj->0); error, Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '{' or '$' in C:...converting_to_object.php on line 11 The reason you can not access values via $obj->0 its because it against PHP variable naming see http://php.net/manual/en/language.variables.basics.php for more information. even if you use ArrayObject you would still have

How to get child class name from parent class

风格不统一 提交于 2019-12-05 09:00:15
I'm trying to accomplish this without requiring a function on the child class... is this possible? I have a feeling it's not, but I really want to be sure... <?php class A { public static function who() { echo __CLASS__; } public static function test() { static::who(); // Here comes Late Static Bindings } } class B extends A { public static function who() { echo __CLASS__; } } B::test(); //returns B ?> Use get_called_class() instead of __CLASS__ . You'll also be able to replace static with self as the function will resolve the class through late binding for you: class A { public static

autoload and namespaces

我们两清 提交于 2019-12-05 06:20:44
问题 I've been working with PHP for a long time, but am now starting to experiment with newer language features such as namespaces. I have a question regarding autoloading that I haven't been able to find an adequate answer to in my web searching. Suppose I have classes in different namespaces: namespace foo\bar\baz; class Quux { } namespace fred\barney\wilma; class Betty { } Then suppose I had an autoloader that assumes that there's a 1:1 mapping between namespaces and directory structures:

Make DateTime::createFromFormat() return child class instead of parent

心不动则不痛 提交于 2019-12-04 18:05:23
问题 I'm extending DateTime do add some useful methods and constants. When using new to create a new object everything is fine but when using the static method createFromFormat it always returns the original DateTime object and of course none of the child methods are available. I am using the following code to circumvent this issue. Is this the best approach? namespace NoiseLabs\DateTime; class DateTime extends \DateTime { static public function createFromFormat($format, $time) { $ext_dt = new

DDD: is it ok to inject a Service into an Entity

瘦欲@ 提交于 2019-12-04 09:38:41
I have a tree of Zone objects: class Zone { protected $parent; public function __construct(Zone $parent) { $this->parent = $parent; } } There are no children nor descendants property in the Zone, because I want to avoid the pain of managing these relationships in the domain model. Instead, a domain service maintains a closure table in the database, to map a zone to all its descendants, at any level. Now, I have a User which can be assigned one or more Zones: class User { protected $zones; public function assignZone(Zone $zone) { $this->zones[] = $zone; } } My problem is that, prior to