Skip to main content

Posts

Lives on the go!

Our today post will focus on how to implement php class and method

A class is a container for objects, and object is items in class. Class is container that we can store all kinds of obejects, such as variable, function etc. Today we will implement class and objects , property, set, get and the rest. If you look at the php class below, this is exactly how to declare empty php class. Php class container with public objects, function set parameters and gets parameters. In php class below, we created two functions, one to set a value and one to get the value, pass the instance object and its value. Now you can copy the below code for your testing. name = $name; } function getname() { return $this->name; } } $username = new KcFuns(); $username->setname('Kenan Chiquado'); echo "Output:"; echo "Username is: ".$username->getname(); echo "----------------------------------"; ?> Php class several objects function and parameters In our second php class implementation, we will lo...
Recent posts

Our today post will focus on how to create php swith case

Php compare different color and return the match What is switch case in php? To make it simple: switch case is usually a method of comparing two objects to decide true or false, negative or positive action. In php script below we will set a variable container with value color and compare it with different color and see which could match the previous value. Copy the php script below your testing. Php switch case to compare digit number and return the match Another method of comparison is setting up a digit number and compare it with another digit number. While running the below code you can change different digit number to the activity of switch case comparison. Now, you can copy the code below or write it manually for your testing. $d = 5; switch ($d) { case 1: echo "Your favourite number is: 1"; break; case 2: echo "Your favourite number is: 2"; break; case 3: echo "Your favourite number is: 3"; break; case 4: e...

Today we will look into how to implement cUrl in php application

Passing json file via cUrl in php We will implement passing json file via cUrl and submit to next server. cUrl is all about special communication between two or more server. Such as server1.com sending data to server2.com. A lot of beginner had always ask endless question about what is cUrl and what cUrl actually does. A simple answer there is: cUrl is a special communication between two or more server. Now, if you look at json code below, it has been neatly written and indented and ready for testing. Launch your notepad copy the json data below and save it as data.json place it in a folder where you saved other php file. { "id": "1", "image": "image\/chiquado.jpg", "fullname": "Kenan Chiquado", "fulladdress": "Udah, Igbo-eze North LGA, Enugu state, Nigeria", "emailaddress": "2348130802790", "phonenumber": "presschiquado@gmail.com...

How to decode json data and print on user interface stream using php script

Printing data retrieved from json file In our previous tutorials we have shown you how to retrieve database information, encode and print it to json file. Now, we will learn how to decode the same json file and print it to user interface stream. If you look and json data format below this is exactly what we retrieve from our database. Put the json file in the same folder where the next php code will be placed. Below is example of our json file named data.json for this testing. { "id": "1", "image": "image\/chiquado.jpg", "fullname": "Kenan Chiquado", "fulladdress": "Udah, Igbo-eze North LGA, Enugu state, Nigeria", "emailaddress": "2348130802790", "phonenumber": "presschiquado@gmail.com", "username": "Chikwado", "password": "web@design&33", "project": "Local ...

Our today post will focus on how to retrieve information from our database and print it in json file

Opening database retrieve user profile and print in json file In our previous discussion we showed you how to store information in database and display it on html stream. Now, we will implement how to print users details to json file. The below code, you can copy and paste or write it manually for your testing. Copy the below code save it as jsontest.php and run it. if you see message "Success!" this means our profile details was successfully created and printed to json file. connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM webdesign"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $profile = array( 'id' => $row["id"], 'image' => $row['image'], 'fullname' => $row["fullname"], 'fulladdress' => $row["fulladdress"], 'emailaddress' ...