php-5.3
How to fix the session_register() deprecated issue?
Don’t use it. The description says: Register one or more global variables with the current session. Two things that came to my mind: Using global variables is not good anyway, find a way to avoid them. You can still set variables with $_SESSION[‘var’] = “value”. See also the warnings from the manual: If you want … Read more
curl posting with header application/x-www-form-urlencoded
<?php // // A very simple PHP example that sends a HTTP POST to a remote site // $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,”http://xxxxxxxx.xxx/xx/xx”); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, “dispnumber=567567567&extension=6”); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/x-www-form-urlencoded’)); // receive server response … curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec ($ch); curl_close ($ch); // further processing …. if ($server_output == “OK”) … Read more
What is ?: in PHP 5.3? [duplicate]
?: is a form of the conditional operator which was previously available only as: expr ? val_if_true : val_if_false In 5.3 it’s possible to leave out the middle part, e.g. expr ?: val_if_false which is equivalent to: expr ? expr : val_if_false From the manual: Since PHP 5.3, it is possible to leave out the … Read more
What does ‘P’ stand for in the DateInterval format?
From the manual Interval specification. The format starts with the letter P, for “period.” Each duration period is represented by an integer value followed by a period designator. If the duration contains time elements, that portion of the specification is preceded by the letter T.
What is the difference between self::$bar and static::$bar in PHP?
When you use self to refer to a class member, you’re referring to the class within which you use the keyword. In this case, your Foo class defines a protected static property called $bar. When you use self in the Foo class to refer to the property, you’re referencing the same class. Therefore if you … Read more
How to fix error with xml2-config not found when installing PHP from sources?
All you need to do instal install package libxml2-dev for example: sudo apt-get install libxml2-dev On CentOS/RHEL: sudo yum install libxml2-devel
How do I use PHP to get the current year?
You can use either date or strftime. In this case I’d say it doesn’t matter as a year is a year, no matter what (unless there’s a locale that formats the year differently?) For example: <?php echo date(“Y”); ?> On a side note, when formatting dates in PHP it matters when you want to format … Read more