Friday la la la-lamp+php ' s OOP

Source: Internet
Author: User
Tags phpinfo phpmyadmin

Hi

Friday ~ ~

1, lamp configuration End Chapter

Five, lamp configuration environment optimization

5.4 How virtual hosts work

Apache's virtual host. Virtual-host

Access different directories with different domains--Manually impersonate DNS

Modifying the host file is possible. Specifically, the host address domain name

Review

[Email protected]:~$ sudo apt-get install apache2

[Email protected]:~$ sudo apt-get install php5
Then load/check php5.load this PHP implementation of the APACHE2 operation module (lamp of each other, is the module's start/connect)
[Email protected]:~$ cat/etc/apache2/mods-enabled/php5.load
[Email protected]:~$ sudo apt-get install Mysql-server

sudo apt-get install apache2 php5 mysql-server php5-mysql

[Email protected]:~$ sudo service mysql restart
[Email protected]:~$ sudo service apache2 restart

----Creating Phpinfo Probes

First install Vim

sudo apt-get install vim

Then switch to the PHP www folder, using the CD command

Cd/var/www/html (Version 14.4)

Then create a PHP file here

sudo vim info.php

Write PHP code

<?php
echo mysql_connect (' localhost ', ' root ', ' hanhan123 ')? ' Hoho ': ' WTF ';

Phpinfo ();
Then the ESC key, enter: Wq Save exit

http://192.168.1.100/info.php Browser Input Validation results

End of review

5.5 Installing phpMyAdmin

--

Apt-get command

sudo apt-get install phpMyAdmin

sudo ln-s/usr/share/phpmyadmin//var/www/pma

Six, server cluster understanding

There are many famous giant server clusters at home and abroad.

For simultaneous processing of large volumes of requests

-----------------------------------

2. OOP Programming for PHP

Iv. advanced practices in OOP

Program Preparation

<?php
Date_default_timezone_set ("PRC");
/**
* 1. The definition of a class begins with the Class keyword followed by the name of the class. The name of a class is typically capitalized in the first letter of each word.
* 2. Defining the properties of a class
* 3. Methods for defining classes
* 4. Instantiating an object of a class
* 5. Working with properties and methods of objects
*/
Class Nbaplayer
{
Definition of a property of a class
Public $name = "Jordan";//define Properties
Public $height = "198cm";
Public $weight = "98kg";
Public $team = "Bull";
Public $playerNumber = "23";

Definition of a method of a class
Public Function run () {
echo "running\n";
}

Public Function jump () {
echo "jumping\n";
}
Public Function dribble () {
echo "dribbling\n";
}
Public Function shoot () {
echo "shooting\n";
}
Public Function dunk () {
echo "dunking\n";
}
Public Function Pass () {
echo "passing\n";
}
}

/**
* 1. When a class is instantiated as an object, the New keyword is used, followed by the name of the class and a pair of parentheses.
* 2. Use an object to perform assignment as you would with other values
*/
$jordan = new Nbaplayer ();
The syntax used for accessing an object's properties is a symbol, followed by the name of the property
echo $jordan->name. " \ n ";
The syntax used by a method of the calling object is a symbol, followed by the name of the method and a pair of parentheses
$jordan->run ();
$jordan->pass ();

?>

4.1 Inheritance

That is, objects of similar parts, can be used in multiple places-to avoid code redundancy, development efficiency increased.

Advantage: defined in the parent class, the subclass does not need to be defined again-high efficiency; for external, consistent (parent class is the same); Override to modify subclasses.

Give me a chestnut.

Class human{
Public $name;
Public $height;
Public $weight;

Public function Eat ($food) {
echo $this->name. "' S eating ". $food." \ n ";
}
}

Humans as a parent class and then NBA players as subclasses

Class Nbaplayer extends human{

Try calling function from the parent class directly from the subclass

$jordan->eat ("Apple");

Output

Jordan ' s eating apple

No problem! subclasses are properties and methods that can call the parent class directly!! (Methods and properties defined in the parent class can be accessed directly on the object of the child class)

After all, from its point of view, the subclass is the extension of the parent class.

In addition, attributes in the parent class can be accessed in subclasses (in fact, the simple understanding is that all subclasses are objects greater than or equal to the parent class, imagine the Venturi graph)

Class inheritance, with extends, only with a "dad"--php single-Inheritance principle

4.2 Access Control

All properties and methods have access options-choose who can access them

Public: Publicly, anywhere

Protected: Protected, by itself and by its subclasses

Private: Privately, can only be accessed by itself

Give me a private chestnut.

In this subclass of Nbaplayer, new additions are defined

Private $age = "44";

Public Function Getage () {
echo $this->name. "' S age is ". $this->age;
}

Try calling private, directly and through the internal public function
$jordan->age;
$jordan->getage ();

Then, about protected, the scope is tightly bound to the parent class and the subclass, that is, the definition of the subclass that curly brace is invalid!

4.3 Static members

Can be simply understood as constants (?). )

Static

Bu Xiang Xie le

Friday la la la-lamp+php ' s OOP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.