Categories
PHP 5

using PHP Values as Variable names and to call Functions

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 […]

Categories
PHP 5

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
PHP 5

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 5

PHP short of statement (Ternanry)

More info can be found at davidwalsh $message = ‘Hello ‘.($user->is_logged_in() ? $user->get(‘first_name’) : ‘Guest’);

Categories
PHP PHP 5 Web Development

PHP & OOP: A Fundemental Tutorial on Object Oriented Programming and PHP

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 […]