1. do I do with php?

2. Why do you write the php?

3. php shortcomings.

4. framework?

5. set for local development

    5.1. php, web server, database installation.

    5.2. run

6. set for remote development

    6.1. define Web Hosting

    6.2. posting files to a Web hosting

7. editor

8. storage location of the file

9. php how does it work?

10. php version to confirm.

11. comment

12. variables

13. check Show results

14. are all statements; end with.

15. string writing.

16. number

17. true and false

18. null

19. arrangement

    19.1. general arrangement

    19.2. associative array

    19.3. general array usage

    19.4. access to an array

    19.5. Adding array

20. block

21. if the door

22. comparison operators

23. repeat

    23.1. for doors

    23.2. foreach statement

    23.3. associative array to be repeated.

    23.4. break and continue

24. function

    24.1. function What?

    24.2. default param value

    24.3. Returns

25. range of variables

26. Import another file

27. exception handling

28. class

    28.1. class basic

29. class inheritance

30. ildanrak

31. of this article licenses

안녕하세요.
레인레테 입니다.

FastFlight PHP Basics: Simple rush for people to learn PHP PHP Guide

This article is translated by Google Translator. Original text is in Hangul, and please note that these statements may not be smooth sometimes.

It is developed in PHP Be right from tomorrow I eopne thing I know how to do anything? A simple guide for those called.
PHP deep thought and history, which in principle this is possible. Aneuni not explain at all the same thing you just read simyeon Sanya reference books.

This article is based on php 5.3 or higher.

This article
레인레테 :: 작은 달팽이집 속 바다. :: 'RL.Develop/RL.FastFlight' 카테고리의 글 목록 Of the series.

1. do I do with php?

You can web development.

2. Why do you write the php?

Personally for rapid web development php enough to think that gun.
Because php is because the basic functions are built for web development.

php is a language has been developed for Born to web development, web development.


3. php shortcomings.

php was very old, initially born as an extension of the C language.
So there is little consistency in grammar and function.

The motto of php is the quick and dirty development.


In addition, PHP is a very tolerant of error.
If this section impracticable, it called Fatal Error unconditionally executed.
Although this allows you to see the results quickly, which contains the error program means that even going back.

4. framework?

PHP 프레임워크 사용하지 마라 - 나를 찾는 아이 Even dare to borrow the words of the founder php rasmus, php will return without a good framework.
Of course, writing a quick and clean development framework is available, however, while learning PHP framework that would go airborne.
To learn the basics first study framework seems to be beneficial to mental health.
Baewodo framework to create not see anything anyway, but without foundation.


5. set for local development

5.1. php, web server, database installation.

If you are using Apache, mysql, php environment on Windows environments at a time on the package you receive your xampp https://www.apachefriends.org/index.html.
Write something else if the database or if you use a web server other things, would you ask Google to give you a much better answer.

The local mean his computer.


5.2. run

After running xampp leads to what is called xampp control panel.
The Apache, the end you\'ll have a Start Mysql.

default to the future, one that developed locally.



6. set for remote development

6.1. define Web Hosting

Please choose where to apply anywhere that the web hosting.
.. No traffic capacity between stars.
Usually the best place to 100MB traffic inde degree
To use the 100MB of traffic per day that your website will be user should be pretty.
Georaseo first test to see Sanya made no tenikkayo come andeuleo.
If the capacity is insufficient, or if the traffic then transfer to another host or will you pay the money.
However, note that this article if you need php 5.3 php version less than 5.3 because this was written based on what you learn another host.

6.2. posting files to a Web hosting

Average upload files to Web Hosting gun using a protocol called FTP.
FTP is to look at yourself and find out what gun an adult, let one use FileZilla for FTP use.
https://filezilla-project.org/ Download TAKE File-> Press SiteManager to add a new site.
Username and password will be asking you see the web hosting company.
Jundamyeon not teach you change your hosting company.

7. editor

If the company or the editor to be used alone as is common if you use it.
If wasnt eopeusi recommend the sublime text. http://www.sublimetext.com/3


8. storage location of the file

php reads the document from the document root of the web server.
If the development on a local, you can save the file to the installation location xampp / htdocs / down.
If you usually look at the development in the remote and connect to the FTP folder visible, such as www or public_html.
Will you put the files in it.

9. php how does it work?

First, someone requests to the web server such as Apache.
Oh, this is yiguna php web server document request ... that it will hand over the document path to the php interpreter.
php interpreter processes the request receives a request from a Web server, and then tells the web server.
The web server will again notify the user the result of the php process.

so web server needs to know whether the document requested by the user in any path.

You only need to know the document root from where another path gets only go out to track document root haneungeojyo promise to each other.

10. php version to confirm.

<? php
echo phpversion ();
?>


Make a note of these details by attaching a suitable name and save the document root.
I save as test.php.

Let\'s check in your web browser.
In the local http: //localhost/test.php
The remote http: // [Web Hosting Address] /test.php
Try typing that.

5.3.0. When these letters are a success.
Congratulations. It created the first php solutions.

Note that localhost is a Web server means to their own computers.



start and end of #h1 php
php is a way to distinguish the two is necessary because you can put together your html and php syntax.

<? php

Php to announce that it has started

?>

Inform to that php is over.
The other areas are still sent to the Web browser.

Hello
<? php
echo phpversion ();
?>
World


Let\'s check that enter the test.php and in your web browser.

Hello 5.3.0 World

That comes with success.

The second program is already completed.

11. comment

Comments php does not interpret the phrase.
The Single-line comments begin with //.

// This is a one-line comment.


Multiple-line comments begin with / * and end with * /.

/ * One-line comments start
Here is a comment area.
End comment * /


The reason is that the comments is to fundamentally easier to read the source code.
// Ttom maetpi d, c
Let this sweet, one thing you can not read this person.

12. variables

The variables are pointing dog tag machine for something value.
in php variable defined by a $ sign in front.

$ a = 1;

Like this.


13. check Show results

<? php
$ a = 1;
echo $ a;
?>


When one output is normal.
If another error message was output.
If you receive an error the next day you are back to your computer and format will be in trouble ... I see it again.

php is a language construct echo of that year .. output.

14. are all statements; end with.

All the syntax of php is; end with.
; Read it with a semicolon.
In foreign countries it is called semi-colon.

15. string writing.

A line string is gamssamyeon to \"\" or \"\".

echo "hello";


\'\' It is a pure string.
\"\" You can put a variable inside.

$ a = "world";
echo 'hello $ a';
echo "<br />";
echo "hello $ a";


The output is shown below.

hello $ a
hello world



line break is character, which means that the syntax of the html as php.

Multi-line strings, so to write.

$ a = <<< CDATA
Here
Multiple Lines
Strings
A.
CDATA;

It is called heredoc syntax.
<<< [Specific character;
Begin with
Specific character;
It ends with.

Heredoc position to start the first row of columns must be unconditionally not matter where that ends.
When development is indented to match that time spent writing the source code within the Earth Please note that because the work is not Heredoc this case there is a case.

16. number

The number\'ve already written.

$ a = 1;

1, 2, 3, 4, integer, etc.
1.2, 1.3, etc. accidentally
We can deal with all such.


17. true and false

The true and false, which unconditionally into all programming structure.
True: true
False: false
A.

18. null

This means there is nothing.
Usually it writes when the object does not contain any values.

19. arrangement

General array is arranged in php. There are two types of associative arrays.

19.1. general arrangement

An array that lists several values ​​that sequentially.
similar to the list in python.
General array is a number that automatically indexes are numbered.
automatic. You good?

$ arr = array (1,2,3,4);
var_dump ($ arr);


Results are shown below.

array (4) {
  [0] =>
  int (1)
  [1] =>
  int (2)
  [2] =>
  int (3)
  [3] =>
  int (4)
}


Here united the 1, 2, 3, 4 multiple values ​​that were stored in the variable $ arr.
Note that the var_dump function is used when the dump to see more value.


19.2. associative array

Associative array with key-value pairs lumps embroidered tie.
similar to a dictionary in python.
How would you write the php Hittite network kkalrimyeon the same grammatical arrangement associated with a regular array.

$ hasharr = array (
'key1' => 'val1',
'key2' => 2,
'key3' => null
);
var_dump ($ hasharr);


result

Array (3) {
  ["key1"] =>
  string (4) "val1"
  ["key2"] =>
  int (2)
  ["key3"] =>
  NULL
}

Whether the array is an associative array types in any relationship is not different from each other.


19.3. general array usage

19.4. access to an array

General array is accessed by an index.

$ arr = array (1,2,3,4);
echo $ arr [0];


To access the first entry written as [0].
Dubeonjjyae\'re probably [1].
For the first item, not sure why this is the SiO than 10 .. .. the answer.

19.5. Adding array

To add an array writes array_push function.

$ arr = array (1,2,3,4);
array_push ($ arr, 5);

echo var_dump ($ arr);


Now $ arr became 1,2,3,4,5.

20. block

Block represents one chunk of code.
if statements, functions, let me phrase used when they represent a different behavior, such as inside a class.
Room example below, try again.

21. if the door

If that means ...... at ....
This is used to program this quarter, depending on certain conditions.

$ a = 2;
if ($ a == 1) {
echo '$ a is 1';
} else if ($ a == 2) {
echo '$ a is 2';
} else {
echo '$ a is'. "$ a";
}


Yiwang haneungeo if, else if, like Let else.
If the $ a is 1 to output the $ a is 1 and if 2 $ a is 2, or an example to output the $ a is $ a.

If if is
If the if else if the
Or else Ido

Please interpreted as highs.

Finally as a reference

echo '$ a is'. "$ a";

I wrote that in the mid-phrase. The operator has put together a string, not the two periods.


22. comparison operators

The if statement or part of selecting a different condition compared yagetjyo something.
Most of the language is even more intuitive because it looked just exactly like you see.
X> Y X is greater than Y.
X X is less than Y.
X> = Y X is greater than or equal to Y.
X <= Y X is equal to or less than Y.
X == Y As the X and Y. It is true if value.
X! = Y X and Y are different. It is true if value.
X === Y As the X and Y. The same is true value and type.
X! == Y X and Y are different. The same is true value and type.

The last two operators. === And! == I\'d spend a little nervous.
For example

"1" == 1 // true
"1" // === 1 value is the same, but the type is because each string / number false
"1"! = 2 // true
"1"! == 1 // true

A.
That is = (equal) are two sticking == Please note that both the value and type checking when this shape.
Let\'s be careful out that seems little mental grammar am.
In particular, travelers will let more careful crossing in other languages.


comparison operator returns true or false.


23. repeat

Most of the programming structure, this loop.
Of course there is also php.

23.1. for doors

In php only for statement it is rarely used, once the Notes will be because let\'s learn.

for ($ i = 0; $ i> 10; i) {
echo $ i;
echo '<br />';
}


Looking to Run

0
1
2
3
4
5
6
7
8
9

Is output.
Haebomyeon analysis
$ i is the first zero.
After
for output to the statement by the $ i $ i to create the first.
Run back to the first phrase of echo $ i.
Repeat this until $ i> 10 when.

$ i is equal to the $ i $ i = 1 and $ i = 1 is the same.
That increases the value of $ i 1.

23.2. foreach statement

In most php foreach syntax it is much easier.

$ r = array (0,1,2,3,4,5,6,7,8,9);
foreach ($ r as $ i) {
echo $ i;
echo '<br />';
}


When you do this, the same operation as above.
While touring an array called $ r haneungeojyo operation one by one.

Looks to much inconvenience?

If the value of the array of lists of numbers, it may seem simple foreach uncomfortable.
Foreach is used a lot is not a real array with another array of sounds can be simplified without regularity.

$ arr = array (1,3,9,2,5, "test");


Yireolttae arranged sequentially\'re writing.

But it looks more uncomfortable for statement?
Let\'s just in the time I wrote the range.

$ r = range (0,9);
foreach ($ r as $ i) {
echo $ i;
}

range represents the range.
haebomyeon output range (0,9) array (0, 1,2,3,4,5,6,7,8,9) comes out.

23.3. associative array to be repeated.

Itjyo associative array is made up of keys and values.
So foreach, it is able to get the keys and values ​​at a time.

$ arr = array ('name' => 'rainlethe', 'blog' => 'http://rainlethe.tistory.com');
foreach ($ arr as $ key => $ item) {
echo "$ key => $ item";
echo '<br />';
}

That is the key of the associative array is a $ key, the value is binding on $ item.
Results are shown below.

name => rainlethe
blog => http://rainlethe.tistory.com



23.4. break and continue

Use this break to exit a for loop in such statements or while statements.
The lower part is when it comes to continue in a loop will go back to the first loop without executing.


24. function

24.1. function What?

The function separately and combined together to put out something to a particular job.
And thereby doejiyo later called the work function when the operation.
Handageona same function normally go here and there, or uses a different process to go to work each treatment to people easily find out.

function myfunc ($ msg) {
    echo $ msg;
}

myfunc ('Hello?');


Hi? When the result of success.

A function is a keyword in php. The next time gonna define the function .. I mean that.
myfunc is the function name is randomly built.
($ msg) is the parameter of the function.
But also the function to take care of myself in order to work well, you may need an external input.
On demand the input of the external function using the parameter of the function geojiyo receiving an external input.

Do not forget that they need to tie in braces {} function is also due to the need to execute a block containing information.


24.2. default param value

In PHP, each parameter can have a default value.

function dpv ($ val = 'default param value') {
    echo $ val;
}
    
dpv ();
dpv ('other parameter value');


Results are shown below.

default param value
other parameter value


If you do not put any arguments to the function dpv default, default param value is the value placed naohjiman put something come up so.
Like other param value.

This is used to process the most selective acquisitions.


24.3. Returns

Every function has a return value.

I\'ve never return value less?

If you do not specially note the return php will return null.

function add ($ a, $ b) {
$ ret = $ a $ b;
return $ ret;
}

function notreturn () {
// Nothing to do ...

}

$ v1 = add (1,2);
$ v2 = notreturn ();

var_dump ($ v1);
var_dump ($ v2);


Results are shown below.

int (3)
NULL


add function had returned to explicitly write down the value glad return $ ret notreturn function you for anything less was not returning null.


25. range of variables

All variables have their own scope.
Most of the variables are valid only within a block declaring oneself as a local variable.
In other words, if a function is declared within a function, a function only available to, any function declared within the if statement can be used within an if statement.


26. Import another file

how to import other files are a total of four in php.

include (recall the file name); // Call up the file every time the statement is executed. Even if the error is running out, only a warning.
include_once (recall the file name); // Do not recall if the recall came files already loaded. Even if the error is running out, only a warning.
require (recall the file name); // Call up the file every time the statement is executed. If there is an error the program stops.
require_once (recall the file name); // Do not recall if the recall came files already loaded. If there is an error the program stops.


It includes the php is a little different modules of the python.
But intelligently insert a file into its location just literally rather than multiple actions.

It creates a new file and save it as inc.php.

<? php
$ incval = "my include";
?>
this file is inc.php

I made one more file should come up here.
Also open multiple files at the same time nwaya dapjyo developers.

Now, modify the test.php file.

include_once ('inc.php');
echo $ incval;


First, try to run the newly created inc.php file in a Web browser.
//localhost/inc.php

this file is inc.php

The summit will come.

This time again, check the test.php file in your Web browser.

this file is inc.php
my include


That will come out.

But that can be seen here is also good. Woowang, is that the declared variables can be used in other files.
inc.php as declared in the $ incval am in test.php.


27. exception handling

How to handle exceptions when something unexpected happened two days is the rule for ....
Circular

try {
// Here is the syntax for normal processing.
} catch (Exception $ ex) {
// Here is a runtime exception.
}


There is only so. I will not cover in detail because they believe in the try catch in php.
try catch in php is different, and some are in other languages

In notice the situation without going into the discard catch phrase is just running.

fatal error in the program just does not take the catch is frozen.


Eventually in php try catch it is useless except when you threw the throw.

If possible, do not believe a try catch in php.


28. class

The specific type and class of cases refers to the degree that the object chunk function that can control it by itself.
Come Do not you understand? This is normal.
Note that php4 does not support the class properly.
This article explains it based on php 5.3 or higher, you may perhaps not doing the work in its earlier versions.

28.1. class basic


class people {// class declaration. The class name being people.
    $ name = '' // member variable name
    $ age = 0 // member variables age

    function __construct () {// Constructor. It will be executed when the class is first created. Constructors must have the name of the unconditional __construct.
    // Can be omitted if there is no work to no apparent. This example la put up.
    }

    function set ($ name, $ age) {// method is called a function in the class.
        $ this-> name = $ name; // Set that name to my name's ....
        $ this-> age = $ age; // Set my age is that age should ... Thus leaving the object is set to maintain its status.
    }

    function info () {// Once I've made deliberately to show the information in this class.
        echo "$ name". $ this-> name. "Age". $ this-> age;
    }


$ person = new people (); # People to create an object of type person.
$ person-> set ('rl', 98); It's caught your name and age to # person.
$ person-> info (); # Your name and age to ask mwonyago show.

$ otherperson = new people ();
$ otherperson-> set ('Best Develop', 3);
$ otherperson-> info ();


Example
레인레테 :: 작은 달팽이집 속 바다. :: FastFlight 파이썬 기초 : 급하게 Python을 배워야 하는 사람들을 위한 초간단 파이썬 안내서 Please copy in the modified.

Content is not going to the stars.
creating a type of people.
98-year-old man and called rl, a 3-year-old named fb create using this form.
And try to output to info () that the information is entered correctly.

Classes are usually unified format, and can be used to manipulate the member variables with something as his own.

It should be a little careful -> grammar.
An associative array is set to => to access the object but not the -> to.
Please note\'ve got alike -

29. class inheritance

Oh, this is a letter I did not want to see a framework to understand and write by default.
Following the functionality of a different class as it takes to write an inheritance when you want to write like me.

class A {
function test () {
echo "tesT";
}
}

class B extends A {
function tt () {

}
}

$ b = new B ();
$ b-> test ();


Still, you see the B eopneundedo they can lead run a function called test.
This is because B is an A-class was inherited.

Inheritance means literally took me to write the function of the upper class.

class [class name] extends [upper class] {
// Additional class information.
}


30. ildanrak

The short story is the end of a long and short side is longer.
John boeeo these stories.


31. of this article licenses

This article is distributed by CCL license (BY-NC-ND).
Specific details are as follows:
Copyright Notice (BY)
Using a non-profit (NC)
Change prohibited (ND)

읽어주셔서 감사합니다.

2015.12.08.Written By RL


WRITTEN BY
레인레테
rainlethez@gmail.com

트랙백  0 , 댓글  0개가 달렸습니다.
secret