This should apply to perl as well: Variable name: $myvar = ‘foo’; ${$myvar} = ‘haswell’; echo $foo RESULT ‘haswell’ Call a function: $type = ‘red’; $myClass->$type(); == $myClass->red(); Taken from: More helpful stuff: ${“variableName”} = 12; {“functionName”}(); $className->{“variableName”}; $className->{“methodName”}(); StaticClass::${“variableName”}; StaticClass::{“methodName”}(); Are there any other Languages that can do this, I know Perl Can… And […]
Category: PHP 5
				
					Categories				
				
			
			PHP dump a variable to a file
$var_str = var_export($data, true); $var = “$var_str”; file_put_contents(‘/var/some/location/on/server/value.txt’, $var);
				
					Categories				
				
			
			Check if PHP Post Variable is set
Info from Stackoverflow if (isset($_POST[“mail”]) && !empty($_POST[“mail”])) { echo “Yes, mail is set”; }else{ echo “N0, mail is not set”; }
				
					Categories				
				
			
			PHP short of statement (Ternanry)
More info can be found at davidwalsh $message = ‘Hello ‘.($user->is_logged_in() ? $user->get(‘first_name’) : ‘Guest’);
PHP & Object Oriented Programming PHP can be used both procedurally and with an object oriented approach. In PHP & procedural programming the emphasis lies with the actions and the steps that must be taken to perform actions such as submitting a form or retrieving a record from a database. In PHP & Object Oriented […]