“PHP runs crappy code really, really well.” – Rasmus Lerdorf
Rasmus Lerdof PHP Talk on PHP
Alles zum Thema Serverseitige Programmierung mit PHP.
Everything concerning server-side programming in PHP.
Rasmus Lerdof PHP Talk on PHP
$clientIpAdress = isset($_SERVER['HTTP_CLIENT_IP'])?$_SERVER['HTTP_CLIENT_IP']:isset($_SERVER['HTTP_X_FORWARDED_FOR'])?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR'];
Do *not* use this on it’s own for security purposes!
The all-out hipster among the PHP frameworks.
We had a neat Web Engineering Group Düsseldorf Meetup at the old Trivago location (they’re currently moving). Once again an awesome event with a very nice lineup of speakers. Enjoyed it a lot.
<?php $urlPathToFileInSameDirectory = (isset($_SERVER['HTTPS'])) ? "https" : "http" . str_replace('/index.php',"",str_replace(basename(__FILE__),"","://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]")).'/MyFileName.txt'; ?>
To prevent perpetual login redircet loops in local/development WordPress installations add this function to your wp-config.php (have it return the users ID you want to authenticate):
function wp_validate_auth_cookie($cookie='',$scheme='') { return 1; // admin user id }
# add to functions.php of your theme function the_title_trim($title) { $title = attribute_escape($title); $findthese = array( '#Protected:#', '#Private:#' ); $replacewith = array( '', // What to replace "Protected:" with '' //What to replace "Private:" with ); $title = preg_replace($findthese, $replacewith, $title); return $title; } add_filter('the_title', 'the_title_trim');
I love Python, I think JavaScript is sort of OK and I did a lot of serious programming in ActionScript 2&3, both of which are quite simular to JS. I was basically forced into doing PHP by the market. I never really liked PHP but I really never hated it either. The thing about PHP is that it’s so specific in its domain and such a hack that no one doing PHP development for a living will go around boasting about the greatness of the language. There is a refreshing lack of arrogance in the PHP community which, in my observation, makes it very easy for n00bs to pick up. As a result we get countless people reinventing the wheel in PHP and discovering basic programming patters anew for them selves and starting yet another Framework/CMS/Whatnot and the results often are really bizar. But the community remains alive that way.
Working with Drupal with a current project because it’s the prime go-to CMS here is like a live alice in wonderland trip. A strange historically grown mess, barely tamed by sanitiy and a relentless chaotic community that all by accident seem to come up with hacks that somehow solve the problem in some way. And yet there’s a solid global corporation building its business all around Drupal [acquia.com]. The surreal hacks with which the Drupal people solve their problems are mindboggling, and yet everybody seems totally OK with it. And Drupals track record of deployments is impressive.
I guess with PHP it’s somehow like the C vs. Lisp argument: C is so shitty compared to Lisp that you have to get yourself together and work as a team, or you won’t get anything done. Hence Lisp has this loner exisitance on the side and all the real work gets done in this ancient C thing.
PHP is a simular thing. It is so bad that no respectable programmer would pick it up voluntarly nowadays, but yet it grew out of Perl (which is worse in some ways), was somewhat of an improvement and was at the right place at the right time. The badness of PHP accounts for its considerable lack of arrogance (compare the PHP community to the Ruby community for instance) and for no one feeling guilty when he does a quick bad hack.
As a programmer you don’t feel dirty when you do bad programming in PHP, you already felt that when you picked PHP as the solution. Hence quite a bit of work gets done in PHP. That’s why PHP has Drupal and Typo3 and Joomla and the Java Community has nothing of that proportions. The barrier of entry into PHP is *very* low which gives it its momentum.
preg_replace("/\/\w*?\.css/", "/", get_stylesheet_uri());
Gibt den Pfad des aktiven Themes zurück, auch wenn dies ein Child-Theme ist. Vorrausgesetzt, das Child Stylesheet ist mit WordPress Bordmitteln im Theme eingebunden und aktiviert.
Returns the path of the actual active theme, even if this is a child theme. This only works if the child themes stylesheet is included with WordPress methods.
Return value comes with trailing Slash!!
Disable FTP requirement for Pluing Installations and Updates / FTP Anforderung für Plugin und Updateinstallation deaktivieren:
//add to wp-config.php define('FS_METHOD','direct');
Pfad zum Plugin in WordPress / Path to plugin in WordPress
plugins_url()."/[PluginDirectoryName]"
site_url(); bloginfo("wpurl"); //check this!
Returns Root Domain URL without trailing slash.
home_url();
Returns URL of the WordPress Home target without trailing slash. Usually is the same as the root domain, but needn’t be!
admin_url();
Returns the URL leading to the WP Admin directory including trailing slash. URLs in WordPress weiterlesen
array_pop(array_filter(explode("/", $_SERVER['REQUEST_URI']), function ($val){return (strlen($val) > 0);}));
(Das ist PHP / This is PHP)
is_int($thisValue = array_pop(array_filter(explode("/", $_SERVER['REQUEST_URI']), function ($val){return (strlen($val) > 0);}))) ? $thisValue : false;
This command only returns a value if the snippet retrieved is an Integer (better for grabbing IDs) – otherwise it returns false / Dieser Befehl gibt den Wert nur zurück, falls das URL Snippet einen Integerwert enthält – ansonsten wird der Wert “false” zurückgeben (praktisch um IDs abzugreifen)
Das hier in die functions.php des aktiven Themes eintragen / Add this to the active themes functions.php:
add_filter( 'auto_update_translation', '__return_false' );