File: HOWTO.html

package info (click to toggle)
php3 1%3A3.0.5-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,348 kB
  • ctags: 9,086
  • sloc: ansic: 76,362; sh: 2,333; php: 1,329; yacc: 1,148; makefile: 970; perl: 763; cpp: 529; awk: 90; sql: 11
file content (394 lines) | stat: -rw-r--r-- 13,400 bytes parent folder | download | duplicates (2)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<head>
 <title>PHP 3.0 SGML HOWTO</title>
</head>

<!-- $Id: HOWTO.html,v 1.10 1998/01/05 10:47:27 ssb Exp $ -->

<body bgcolor="#ffffff" text="#000000">

<center>
<h1>PHP 3.0 SGML HOWTO</h1>
Stig Bakken, <a href="mailto:ssb@guardian.no">ssb@guardian.no</a> <br>
<font size="-1">$Date: 1998/01/05 10:47:27 $ $Revision: 1.10 $</font> <br>
</center>

<hr>

<blockquote>
<h3>Contents</h3>
<a href="#tools"><font size="+1">1. Tools</font></a><br>
<a href="#editor">1.1. SGML Editor</a><br>
<a href="#sgml-tools">1.2. Conversion tools</a><br>
<a href="#writing"><font size="+1">2. Writing SGML documents</font></a><br>
<a href="#linuxdoc">2.1. LINUXDOC reference</a><br>
<a href="#phpdoc.example">2.2. PHPDOC startup example</a><br>
<a href="#phpdoc">2.3. PHPDOC reference</a><br>
<a href="#phpdoc.dtd"><font size="-1">2.3.1. Document structure</font></a><br>
<a href="#phpdoc.tags"><font size="-1">2.3.2. PHPDOC elements</font></a><br>
<a href="#phpdoc.types"><font size="-1">2.3.3 Variable types</font></a><br>
<a href="#connecting"><font size="+1">3. Connecting stuff</font></a><br>
<a href="#connecting.phpdoc">3.1. New PHPDOC files</a><br>
<a href="#connecting.labels">3.2. Label name conventions</a><br>
<a href="#convert"><font size="+1">4. Converting from SGML</font></a><br>
<a href="#convert.html">4.1. HTML</a><br>
<a href="#convert.text">4.2. Plain text</a><br>
<a href="#convert.text">4.3. Other formats...</a><br>
</blockquote>

<hr>

<p> For now this document describes how to find the tools you need on
UNIX.  Since I am not a Windows user myself, information about SGML on
Windows will show up as soon as it has been gathered.  This means that
Windows users have to give some feedback.

<a name="tools"></a><h1>1. Tools</h1>

<a name="editor"></a><h2>1.1. SGML Editor</h2>

<p> Although it is possible to use a simple text editor such as vi or
notepad to write the SGML, it is recommended to use an SGML editor
that helps you along and makes sure your document is proper SGML
conforming to the used document type definition (DTD).

<p> A pretty good and free SGML editor is Emacs or XEmacs with PSGML.
XEmacs is a fancier Emacs with better X support and a pile of Emacs
Lisp packages included.  Emacs is ported to Windows 95/NT.

<p>URLs:

<ul>
  <li><a href="ftp://ftp.gnu.org/pub/gnu/emacs-20.2.tar.gz">
      ftp://ftp.gnu.org/pub/gnu/emacs-20.2.tar.gz</a>
  <li><a href="ftp://ftp.xemacs.org/pub/xemacs/xemacs-20.2/">
      ftp://ftp.xemacs.org/pub/xemacs/xemacs-20.2/</a>
  <li><a href="ftp://ftp.lysator.liu.se/pub/sgml/psgml-1.0.1.tar.gz">
      ftp://ftp.lysator.liu.se/pub/sgml/psgml-1.0.1.tar.gz</a>
  <li><a href="http://ftp.sunet.se/pub/os/Win32/ntEmacs/docs/ntemacs.html">
      http://ftp.sunet.se/pub/os/Win32/ntEmacs/docs/ntemacs.html</a>
</ul>

<p> If you do not use XEmacs you probably have to add this to your
<tt>~/.emacs</tt> file to make sure Emacs finds the installed files:

<pre>
 (add-to-list 'load-path
   (expand-file-name "<i>PREFIX</i>/share/emacs/site-lisp/psgml"))
</pre>

<p> Replace <i>PREFIX</i> with the prefix you used when installing psgml
(the default is <tt>/usr/local</tt>).

<p> Anyway you'll need this in your <tt>~/.emacs</tt> to load psgml at
startup and make sure psgml is used for all files with <tt>.sgml</tt>
file ending:

<pre>
 (autoload 'sgml-mode "psgml" "Major mode for editing SGML files." t)
</pre>

<p> The existing <tt>.phpdoc</tt> files have "<tt>&lt;!-- -*- SGML -*-
--&gt;</tt>" in their header.  When Emacs sees a pattern like "<tt>-*-
foo -*-</tt>" in the first line of a file, it tries to go into
<i>foo</i>-mode.  So to activate psgml for <tt>.phpdoc</tt> files you
can include the above SGML comment in the first lines of the files you
write.  Or, you can tell Emacs it should always open <tt>.phpdoc</tt>
files in sgml-mode by putting this in <tt>~/.emacs</tt>:

<pre>
 (add-to-list 'auto-mode-alist '("\\.phpdoc$" . sgml-mode))
</pre>

<p> For Windows users without NTFS, the <tt>.emacs</tt> file is called
<tt>_emacs</tt>, and resides in the directory given by the HOME
environment variable or <tt>C:/</tt>.

<p><i>If you have information about other SGML editors, please <a
href="mailto:ssb@guardian.no">send it</a>.</i>

<a name="sgml-tools"></a><h2>1.2. Conversion tools</h2>

SGML-Tools (previously known as "Linuxdoc-SGML") contains almost all
the things you is needed to verify and convert PHP's SGML
documentation (you need Perl, too).  Use version <b>1.0.2</b> of
SGML-Tools.

<p>URLs:

<ul>
  <li><a href="http://www.xs4all.nl/~cg/sgmltools/">
      http://www.xs4all.nl/~cg/sgmltools/</a>
</ul>

<hr>

<a name="writing"></a><h1>2. Writing SGML documents</h1>

<a name="linuxdoc"></a><h2>2.1. LINUXDOC reference</h2>

<a name="linuxdoc"></a><h2>2.2. PHPDOC startup example</h2>

<a name="phpdoc"></a><h2>2.3. PHPDOC reference</h2>

<a name="phpdoc.dtd"></a><h3>2.3.1. Document structure</h3>

The structure of PHPDOC can be represented with the following element
tree.  Each level in the tree represents the possible contents of the
tag on the level above.

<dl>
  <dt><a href="#phpdoc.phpdoc">PHPDOC</a> (1)
  <dd><dl>
    <dt><a href="#phpdoc.funcdef">FUNCDEF</a> (*)
    <dd><dl>
      <dt><a href="#phpdoc.arg">ARG</a> (*)
      <dd><a href="#phpdoc.text"><i>text</i></a>
      <dt><a href="#phpdoc.returns">RETURNS</a> (1?)
      <dd><a href="#phpdoc.text"><i>text</i></a>
      <dt><a href="#phpdoc.text"><i>text</i></a>
    </dl>
    <dt><a name="phpdoc.text"></a>text - <i>any of these elements:</i>
    <dd><dl>
      <dt><a href="#phpdoc.aref">AREF</a>
      <dd><a href="#phpdoc.text"><i>text</i></a> except AREF
      <dt><a href="#phpdoc.fref">FREF</a>
      <dd><a href="#phpdoc.text"><i>text</i></a> except FREF
      <dt><a href="#phpdoc.func">FUNC</a>
      <dd><a href="#phpdoc.text"><i>text</i></a> except FUNC
      <dt><a href="#phpdoc.var">VAR</a>
      <dd><a href="#phpdoc.text"><i>text</i></a> except VAR
      <dt><a href="#phpdoc.lit">LIT</a>
      <dd><a href="#phpdoc.text"><i>text</i></a> except LIT
      <dt><a href="#phpdoc.lit">CLASSREF</a>
      <dd><a href="#phpdoc.text"><i>text</i></a> except CLASSREF
      <dt><a href="#phpdoc.lit">CONFREF</a>
      <dd><a href="#phpdoc.text"><i>text</i></a> except CONFREF
    </dl>
  </dl>
</dl>

<a name="phpdoc.tags"></a><h3>2.3.2. PHPDOC elements</h3>

This is a complete list of all PHPDOC tags with all their attributes
and an explaination of their purpose and usage.

<dl>

  <dt><a name="phpdoc.phpdoc"></a><b>PHPDOC</b>
  <dd>The top-level tag, the start tag must be included, but the
    end-tag may be omitted.  Attributes: <dl>
      <dt><b>TITLE</b> (required)
      <dd>A title of this part of the documentation.
    </dl>
    <p>

  <dt><a name="phpdoc.funcdef"></a><b>FUNCDEF</b>
  <dd>Documents a PHP function.  Attributes: <dl>
    <dt><b>NAME</b> (required)
    <dd>The function name.
    <dt><b>CAT</b> (required)
    <dd>What category of functions and classes this function belongs to.
        <br><i>A list of valid categories may be added later.</i>
    <dt><b>RET</b> (required)
    <dd>What type this function returns.  See <a
        href="#phpdoc.phptyp">phpdoc types</a> for possible values.
    <dt><b>FIRSTIN</b> (optional)
    <dd>Which PHP version this function first appeared in.
    </dl>
    <p>

  <dt><a name="phpdoc.arg"></a><b>ARG</b>
  <dd>Function argument/parameter.  Attributes: <dl>
    <dt><b>NAME</b> (required)
    <dd>The parameter name (only for documentation reference).
    <dt><b>OPTIONAL</b> (optional) defaults to MANDAT
    <dd>Can be empty (<tt>&lt;ARG OPTIONAL ...&gt;</tt>) or have the
      value MANDAT or OPTIONAL.  MANDAT means that this argument is
      mandatory--it must be supplied.
    <dt><b>TYPE</b> (required)
    <dd>The type of this argument.  See <a
        href="#phpdoc.phptyp">phpdoc types</a> for possible values.
    <dt><b>FIRSTIN</b> (optional)
    <dd>Which PHP version this argument was introduced in (if it was
        introduced later than the function was.)
    </dl>
    <p>

  <dt><a name="phpdoc.returns"></a><b>RETURNS</b>
  <dd>Describes what a function returns.  No attributes. <p>
 
  <dt><a name="phpdoc.aref"></a><b>AREF</b>
  <dd>Refers to an argument in the current
      <a href="#phpdoc.funcdef">FUNCDEF</a> or
      <a href="#phpdoc.method">METHOD</a>.  Attributes: <dl>
    <dt><b>NAME</b> (required)
    <dd>Name of the attribute given in the
        <a href="#phpdoc.arg">ARG</a> tag.
    </dl>
    <p>

  <dt><a name="phpdoc.fref"></a><b>FREF</b>
  <dd>Refers to a function.  Attributes: <dl>
    <dt><b>NAME</b> (required)
    <dd>Name of the function referred to.
    </dl>
    <p>

</dl>

<a name="phpdoc.types"></a><h3>2.3.3 Variable types</h3>

<dl>
<dt>Several of PHPDOC's attributes take a <i>PHP type</i> as a
parameter.  The permitted PHP type identifiers are:
<dd>
<table>
 <tr>
  <th>Type</th>
  <th>Description</th>
 </tr>
 <tr>
  <td>int</td>
  <td>PHP's integer type</td>
 </tr><tr>
  <td>float</td>
  <td>PHP's float type</td>
 </tr><tr>
  <td>string</td>
  <td>PHP's string type</td>
 </tr><tr>
  <td>array</td>
  <td>a numbered array of any PHP types</td>
 </tr><tr>
  <td>assoc</td>
  <td>an associative array of any PHP types</td>
 </tr><tr>
  <td>object</td>
  <td>an object</td>
 </tr><tr>
  <td>mixed</td>
  <td>any PHP type</td>
 </tr><tr>
  <td>varargs</td>
  <td>variable number of arguments, type not specified</td>
 </tr><tr>
  <td>void</td>
  <td>nothing</td>
 </tr>
</table>
</dl>

<hr>

<a name="connecting"><a><h1>3. Connecting stuff</h1>

<a name="connecting.phpdoc"></a><h2>3.1. New PHPDOC files</h2>

The main file for the documentation is <tt>manual.sgml</tt>.  This
file uses <i>entities</i> (can be compared to a combination of #define
and #include in C) to include text from other files.  The entities
that include the PHPDOC files are defined in the <i>preamble</i> of
<tt>manual.sgml</tt>, which is the section between the "[" character
on the first (DOCTYPE) line and "]&gt;".

<p> Steps involved in connecting a new PHPDOC file:

<ol>
 <li> Let us say you have written functions/ldap.phpdoc.  You should
      then add this to the preamble:
<pre>
<b>&lt;!entity ldapref system "functions/ldap.sgml"&gt;</b>
</pre>

      This tells the SGML parser that when "ldapref" is referenced it
      should read the file <tt>functions/ldap.sgml</tt>.<p> <em>Note
      that the file name extension used here is not <tt>.phpdoc</tt>,
      but <tt>.sgml</tt>.  The Makefile handles the conversion.</em>
      <p>

 <li> Refer to the <i>ldapref</i> entity where you want to include it.
      Keep in mind that PHPDOC documents are converted into LINUXDOC
      sections.  Internal functions should be added to the "internal
      functions" chapter in <tt>chapters/functions.sgml</tt>.  Add
      something like this (the bold part is what to add):
<pre>
&lt;chapt&gt;Internal functions
 ...
 <b>&amp;ldapref;</b>
 ...
</pre>

 <li> Then, to make sure the .phpdoc file is converted to .sgml,
      you have to tell make about it.  Add the <u>.sgml</u> file to
      the FUNCREF variable in <tt>Makefile.in</tt>.  Example (the bold
      text is the change):
<pre>
FUNCREF=functions/oracle.sgml \
        <b>functions/ldap.sgml \</b>
	functions/math.sgml \
	functions/mysql.sgml \
	functions/pgsql.sgml \
	functions/strings.sgml \
	functions/adabas.sgml
</pre>

 <li> Finally, regenerate <tt>Makefile</tt>:
<pre>
(cd .. ; ./config.status)
</pre>

</ol>

<a name="connecting.labels"></a><h2>3.2. Label name conventions</h2>

When making or refering to labels in the LINUXDOC files, there are
some conventions that should kept:

<ul>
 <li> Internal functions have labels of the form
      <tt>func:<i>function_name</i></tt>.
 <li> Arguments to configure (when installing) have labels like the
      argument names.  For example, the --with-system-regex option has
      the label <tt>with_system_regex</tt>
</ul>
<hr>

<a name="convert"></a><h1>4. Converting from SGML</h1>

<a name="convert.html"></a><h2>4.1. HTML</h2>

You convert all the SGML files to HTML by running "<tt>make html</tt>".
The current Makefile setup splits the chapters and appendices into
separate files.  The main file is called <tt>manual.html</tt>, and the
other files are <tt>manual-<i>n</i>.html</tt>.

<p>If sgml2html shows some error messages like this:
<pre>
  sgml2html -l -2 manual.sgml
  Making manual.html from manual.sgml.
  Problem with @@ref(id = security)!
  Problem with @@ref(id = func:include)!
  Problem with @@ref(id = func:pg_pconnect)!
  Problem with @@ref(id = func:stripslashes)!
</pre>
..it is because of references that point to labels that do not exist.
See <a href="#connecting.labels">label name conventions</a>.

<a name="convert.text"></a><h2>4.2. Plain text</h2>

You convert all the SGML files to plain text by running "<tt>make
text</tt>".  The results can be seen in <tt>manual.txt</tt>.

<p> <i>Note: there seems to be a bug in the 0.99.0 sgml2txt filter
that messes up the section numbering in the table of contents.</i>

<a name="convert.text"></a><h2>4.3 Other formats...</h2>

SGML-Tools supports converting SGML to info, LaTeX, lyx and rtf as
well.  PHP's documentation should be convertable to any of these
formats in theory, but I have not tested it good enough to document it
here yet.

<p><hr>
<i>Send feedback and questions to
<a href="mailto:ssb@guardian.no">ssb@guardian.no</a></i>