File: basic-syntax.xml

package info (click to toggle)
phpdoc 20020310-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 35,272 kB
  • ctags: 354
  • sloc: xml: 799,767; php: 1,395; cpp: 500; makefile: 200; sh: 140; awk: 51
file content (122 lines) | stat: -rw-r--r-- 3,997 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?xml version="1.0" encoding="utf-8"?>
<chapter id="language.basic-syntax">
	<title>기본 문법(Basic syntax)</title>
	<sect1 id="language.basic-syntax.phpmode">
		<title>HTML로부터 빠져나오기(Escaping from HTML)</title>
		<para>
     HTML로부터 빠져나와 "PHP code mode"로 들어가는 방법은 다음 4가지가 있다 : 
		</para>
		<para>
			<example>
				<title>Ways of escaping from HTML</title>
				<programlisting>
1.  &lt;? echo ("this is the simplest, an SGML processing instruction\n"); ?&gt;
 
2.  &lt;?php echo("if you want to serve XHTML or XML documents, do like this\n"); ?&gt;

3.  &lt;script language="php"&gt; 
        echo ("some editors (like FrontPage) don't
              like processing instructions");
    &lt;/script&gt;

4.  &lt;% echo ("You may optionally use ASP-style tags"); %&gt;
    &lt;%= $variable; # This is a shortcut for "&lt;%echo .." %&gt;
      </programlisting>
			</example>
		</para>
		<para>
	첫번째 방법은 short tags가 enable되어 있어야 사용가능하다. 
	PHP config file (php.ini)의 <link linkend="ini.short-open-tag">short_open_tag</link>을 설정을 해 주거나,
	컴파일시에 <command>configure</command> 스크립트의 옵션으로 --enable-short-tags을 주어 설정할 수 있다.
    </para>
		<para>
	두번째 방법은 일반적으로 가장 선호되는 방법이다. 
	이 방법은 차세대 언어인 XHTML에서도 사용가능하다.
    </para>
		<para>
	네번째 방법은 ASP-style tags가 enable되어 있어야 사용가능하다. 
	PHP config file (php.ini)의 <link linkend="ini.asp-tags">asp_tags</link>을 통해 설정한다.
			<note>
				<para>ASP-style tags는 3.0.4부터 지원된다.</para>
			</note>
		</para>
		<para>
	닫는 괄호는 newline을 포함한다.
		</para>
	</sect1>
	<sect1 id="language.basic-syntax.instruction-separation">
		<title>명령 구분 기호(Instruction separation)</title>
		<simpara>
	각각의 명령은 C나 Perl과 같은 기호를 사용하여 구분한다. 즉, 한 문장은 ;(세미콜론)으로 종료한다.
		</simpara>
		<para>

	PHP의 종료택인 ?&gt;는 문장의 끝이라는 의미도 함께 가지고 있다. 따라서 다음 두 개의 문장은 동일하다.:
     <informalexample>
				<programlisting>
&lt;?php
    echo "This is a test";
?>

&lt;?php echo "This is a test" ?>
      </programlisting>
			</informalexample>
		</para>
	</sect1>
	<sect1 id="language.basic-syntax.comments">
		<title>주석문 (Comments)</title>
		<para>
     PHP는 'C'와 'C++', Unix shell 형태의 주석문을 모두 제공한다. 예를 들어 :

    <informalexample>
				<programlisting>
&lt;?php
    echo "This is a test"; // C++ 형태의 한줄 주석
    /* 여러줄의 주석
       이줄까지 주석처리 된다 */
    echo "This is yet another test";
    echo "One Final Test"; # shell 형태의 한줄 주석
?>
     </programlisting>
			</informalexample>
		</para>
		<simpara>
	한줄짜리 주석문은 라인의 끝이나, 해당 php 코드 블록의 끝에서 끝난다.
		</simpara>
		<informalexample>
			<programlisting>
&lt;h1>This is an &lt;?php # echo "simple";?> example.&lt;/h1>
&lt;p>The header above will say 'This is an example'.
</programlisting>
		</informalexample>
		<simpara>
	'C' 형태의 주석문은 중복해서 사용하지 않도록 주의하자.
		</simpara>
		<informalexample>
			<programlisting>
&lt;?php
 /* 
    echo "This is a test"; /* 이 주석은 중복 사용(주석내의 주석)되었으므로 문제의 소지가 있다 */
 */
?>
    </programlisting>
		</informalexample>
	</sect1>
</chapter>
<!-- Keep this comment at the end of the file
 Local variables:
 mode: sgml
 sgml-omittag:t
 sgml-shorttag:t
 sgml-minimize-attributes:nil
 sgml-always-quote-attributes:t
 sgml-indent-step:1
 sgml-indent-data:t
indent-tabs-mode:nil
 sgml-parent-document:nil
 sgml-default-dtd-file:"../manual.ced"
 sgml-exposed-tags:nil
 sgml-local-catalogs:nil
 sgml-local-ecat-files:nil
 End:
 -->