At some point I’ll get all of my Scala “date utilities” together in a single class (object, actually), but until then, here are a couple of date utility methods I wrote for my Scrupal6 project (a replacement for Drupal 6):
PHP FAQ: How do I remove all non-printable characters from a string in PHP?
I don’t know of any built-in PHP functions to remove all non-printable characters from a string, so the solution is to use the
preg_replace function with an appropriate regular expression.
I’m not going to comment on the following code too much or provide support for it, but (a) if you need to create an XML Sitemap for a Drupal 8 website, and (b) you don’t like the Drupal 8 sitemap modules that are available, then (c) this PHP script can serve as a starting point for you.
As a quick note, I was able to fix this error in the Drupal simple_mobile_redirect module:
[Sun Mar 01 14:23:25 2015] [error] PHP Notice: Undefined index: HTTP_ACCEPT in /var/www/example.com/html/sites/all/modules/simple_mobile_redirect/simple_mobile_redirect.module on line 121
by changing this line of PHP code:
If you need to see a simple PHP example that converts an array of data to a JSON string using the
json_encode function, I hope this little script is helpful:
Here are two PHP scripts I just wrote that use
curl_setopt. The first example makes a GET request, and the second example makes a POST request, and passes JSON data to the web service it accesses.
A PHP curl GET request
This first one makes an HTTP GET request and prints the data that is returned by the URL that it hits:
A nice graphic on the use of open source tools on the internet.
I like PHP for certain tasks, but I thought this was funny. From this link on Twitter.
There was a little funky activity on a client's Drupal 6 website that was hosted at GoDaddy, and without having access to an Apache access log file, I wanted to be able to see what was going on. So I wrote the following PHP code snippet to do some manual logging, and placed it in the Drupal theme's