PHP – Mobile Detect
October 21, 2014 | Mobile App Design and Development, PHP, Responsive Web Design, Web Design and Programming 0 Comments

What a sweet gem I found! It’s at http://mobiledetect.net/. This will detect or figure out what device the visiting guest is using. Great for responsive design projects, although, Bootstrap can handle that too.
Unity3D Multiplayer Game
This is an ongoing personal project I work on when I need a bit of fun and sanity. Here’s the link to the test page where the game currently lives. I update it now and again. I also built a custom REST API for the scoreboard and integration with a CMS database.
PHP Classes – How to Create a Class with a Method Function Return
class PHPClassWithMethodAndReturn { /*Define your variables*/ /*Create our custom function and indicate /*Passed parameters need to be assigned /*This is how we will output the value. return $ret; } } //create a class //Call the method and pass two parameters and output using echo.
var $fname;
var $lname;
it will be accepting two parameters.*/
function ShowInfo($fname,$lname) {
values so we can use them.*/
$this->fname = $fname;
$this->lname = $lname;
will assign the final value to a return variable*/
$ret = "The name of the person is " . $this->fname;
$ret.= "The last name is " . $this->lname;
$myPHPClassWithMethodAndReturn = new PHPClassWithMethodAndReturn;
echo $myPHPClassWithMethodAndReturn->ShowInfo("James", "Tadeo");
?>
PHP Classes – How to Create a Class with a Method Function
class PHPClassExampleMethod { /*Define your variables*/ /*Create our custom function and indicate /*Passed parameters need to be assigned /*This is how we will output the value. } } //create a class //Call the method and pass two parameters ?>
var $fname;
var $lname;
it will be accepting two parameters.*/
function ShowInfo($fname,$lname) {
values so we can use them.*/
$this->fname = $fname;
$this->lname = $lname;
We concatenate strings and values.*/
echo "The name of the person is " . $this->fname;
echo "Their last name is " . $this->lname;
$myPHPClassWithMethod = new PHPClassExampleMethod;
$myPHPClassWithMethod->ShowInfo("James", "Tadeo");
PHP Classes – How to Create a Class
// remember to name the file PHPClassExample.php if we plan on using it as part of an includes file. class PHPClassExample { /*Define you variables and do an immediate value assignment*/ } // create a class /*Access the class value for the corresponding value, notice we don't need to add the $ in front of the variable, that's because echo $myPHPClass->fname; ?>
var $fname = "James";
var $lname = "Tadeo";
$myPHPClass = new PHPClassExample;
we already defined it in the class*/
echo $myPHPClass->lname;
PHP – Randomize Image Display
There are times when we need to randomize a value. For example, we want to be able to randomize images that appear on a page. Here’s a simple starting point I’ve used in the past to do this.
// get a random number // plug value in the switch statement - it'll pull up value and serve it up case 0; case 1: case 2: case 4: default: // spit out the image value (we'll need to wrap this in an img src tag ?>
$rndNumber = rand(0,3);
switch($rndNumber) {
$rndImageToUse = "mypic0.png";
break;
$rndImageToUse = "mypic1.png";
break;
$rndImageToUse = "mypic2.png";
break;
$rndImageToUse = "mypic3.png";
break;
$rndImageToUse = "mypic4.png";
}
echo $rndImageToUse;
Web Design – How to Show Your Server’s php.ini File Info
March 5, 2011 | PHP, Web Design and Programming 0 Comments
<?php
echo php();
?>
An unassuming looking script, but it does so much.