PHP is an object-oriented programming language, which means that you can create objects, which can contain variables and functions.
<!DOCTYPE html> <html> <head> <title> Introduction to Object-Oriented Programming </title> <link 'text/css' rel='stylesheet' href='style.css'/> </head> <body> <p> <?php // The code below creates the class class Person { // Creating some properties (variables tied to an object) public $isAlive = true; public $firstname; public $lastname; public $age; // Assigning the values public function __construct($firstname, $lastname, $age) { $this->firstname = $firstname; $this->lastname = $lastname; $this->age = $age; } // Creating a method (function tied to an object) public function greet() { return "Hello, my name is " . $this->firstname . " " . $this->lastname . ". Nice to meet you! :-)"; } } // Creating a new person called "excellent 12345", who is 12345 years old ;-) $me = new Person('excellent', '12345', 12345); // Printing out, what the greet method returns echo $me->greet(); ?> </p> </body> </html>
0 Comments
#include <iostream>
#include <cmath> using namespace std; int main(void) { float value, square_root; cout << "Enter your number now: " << endl; cin >> value; if(value >= 0.0) { square_root = sqrtf(value); cout << "You have entered: " << value << endl; cout << "Your square root is: " << squareroot << endl; } return 0; } #!/usr/bin/env python
# Fitness Calculator # Coded By Vitali from datetime import datetime now = datetime.now() print "%s/%s/%s %s:%s:%s" % (now.month,now.day,now.year,now.hour, now.minute,now.second) print "Welcome to Fitness Calculator!" name = raw_input("Please Enter Your First and Last Name:") exercise = input("How many calories have you burned today?") meal = input("How many calories have you consumed today?") goal = input("How many calories would you like to cut per day?") total = exercise - meal print "Good day%s, so your difference is %s calories, your goal is %s calories, and your meal is %s calories." % (name, total, goal, meal) print "Thank you for using this Fitness Calculator!" print "Please leave us your feedback!" def feedback(): print "This is the feedback zone!" answer = input("How do you rate it from 1 to 10?") if answer < 6: print "Thank you! We will do my best to improve this application in future!" else: print "Thank you! We are glad that you have enjoyed using this application!" Becoming a programmer is deeply connected with the years-long study of cybersecurity, penetration testing, digital forensics, and information security.
It forces me to draw from all disciplines I have learned. It is my test of perseverance, creativity, and knowledge that appeared to be also, rather unexpectedly, the catalyst in my decision to study programming. |
AuthorVitali Kremez Archives
January 2016
Categories |