php-5.3

In PHP, how do you get the called aliased class when using class_alias?

℡╲_俬逩灬. 提交于 2019-12-10 13:21:45
问题 I have a class that sets up a class alias for other class names. When a function is called inside of this class via the aliased class, I need to know which alias was used. Is there a way to do this in PHP? I have tried the following code: class foo { public static function test() { var_dump(get_called_class()); } } class_alias('foo', 'bar'); foo::test(); bar::test(); Which outputs: string 'foo' (length=3) string 'foo' (length=3) But I want bar::test(); to output string 'bar' (length=3)

Special characters with dompdf and php

我的梦境 提交于 2019-12-10 11:47:39
问题 I have a question: I tried to export a pdf with dompdf and php but I can't do this and I dont understand where is my problem, so my code is: public function generateTitlePage($company) { $this->load->library('dompdf_gen'); $html=' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <div style="margin-top:20px;text-align: center;font-weight: bold"> Company:'.$company.' </div> </body> <html>'; $dompdf = new DOMPDF(); $html = stripslashes($html);

PHP Create Timeslots with break timing using DatePeriod

家住魔仙堡 提交于 2019-12-10 09:32:48
问题 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

The header function is not working on online server?

ⅰ亾dé卋堺 提交于 2019-12-08 15:05:14
问题 hi i just dont understand why my code is not working. i am using yahoo server for my site. This is my logout code.(which is successfully run on localhost) but when i upload this code online then its not work. plz help <?php //logout code include("../Config.php"); if (!isset ($_SESSION['username'])) { header( 'HTTP/1.1 301 Moved Permanently' ); header('Location: ../index.php'); if (!headers_sent()) { header('Location: http://www.mysite.com/index.php'); exit; } } else { $_SESSION = array();

PHP DateTime class just like v5.3 for PHP 5.2

做~自己de王妃 提交于 2019-12-08 05:11:04
问题 I've found a few problems in applications I've been doing where methods like DateTime::diff would be of much assistance, but my host with PHP 5.2 does not support DateTime::diff or any other from 5.3. Can anyone point to a class implementation similar to PHP's DateTime class from v5.3, but working for PHP 5.2? Thanks in advance 回答1: I use following wrapper class in my php5.2 apps: http://pastebin.ca/2051944. Untill php5.3 was released - it saves much my time 来源: https://stackoverflow.com

Show Full Stack Trace on PHP Command Line

落爺英雄遲暮 提交于 2019-12-08 03:23:50
问题 Problem My PHP Stack Trace is abbreviated: Stack trace: #0 /www/html/table/app/create.php(128): SoapClient->__call('call', Array) #1 /www/html/table/app/create.php(128): SoapClient->call('5e81ad4c12668ec...', 'table.ad...', Array) Expected Outcome I want to see the part that is hidden by the ... when running php from the command line. How do I make php show the full message? 回答1: You can surround it in a try ... catch and then do a var_dump on the exception. try { // the code that throws an

Gettext not working, no error messages, using php 5.3

折月煮酒 提交于 2019-12-08 01:04:00
问题 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

How to get child class name from parent class

南笙酒味 提交于 2019-12-07 03:02: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 ?> 回答1: Use get_called_class() instead of __CLASS__ . You'll also be able to replace static

Strange PHP 5.3 issue with date diff calculating difference in days

断了今生、忘了曾经 提交于 2019-12-06 23:59:34
问题 I am experiencing a rather strange problem using PHP 5.3's date diff function to calculate the difference in days between two dates. Below is my code: $currentDate = new DateTime(); // (today's date is 2012-1-27) $startDate = new DateTime('2012-04-01'); $diff = $startDate->diff($currentDate); $daysBefore = $diff->d; echo $daysBefore; The above code displays 4 as the value of the $daysBefore variable. Why is PHP displaying a difference of 4 days between the dates 27th Jan 2012 and 1st April

Show Full Stack Trace on PHP Command Line

折月煮酒 提交于 2019-12-06 12:13:42
Problem My PHP Stack Trace is abbreviated: Stack trace: #0 /www/html/table/app/create.php(128): SoapClient->__call('call', Array) #1 /www/html/table/app/create.php(128): SoapClient->call('5e81ad4c12668ec...', 'table.ad...', Array) Expected Outcome I want to see the part that is hidden by the ... when running php from the command line. How do I make php show the full message? You can surround it in a try ... catch and then do a var_dump on the exception. try { // the code that throws an exception } catch ( Exception $e ) { var_dump( $e->getTrace() ); } 来源: https://stackoverflow.com/questions