Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 5356

php-manual-pt_BR-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Using PHP</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="FAQ: Perguntas Mais Freqüentes"
HREF="faq.html"><LINK
REL="PREVIOUS"
TITLE="Build Problems"
HREF="faq.build.html"><LINK
REL="NEXT"
TITLE="PHP and HTML"
HREF="faq.html.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="chapter"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="faq.build.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="faq.html.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="faq.using"
>Capítulo 55. Using PHP</A
></H1
><P
>&#13;   This section gathers many common errors that you may face 
   while writing PHP scripts.
  </P
><DIV
CLASS="qandaset"
><DL
><DT
>1. <A
HREF="faq.using.html#faq.using.anyform"
>&#13;      I would like to write a generic PHP script that can handle data coming 
      from any form. How do I know which POST method variables are available?
     </A
></DT
><DT
>2. <A
HREF="faq.using.html#faq.using.addslashes"
>&#13;      I need to convert all single-quotes (') to a backslash 
      followed by a single-quote (\'). How can I do this with a 
      regular expression?  I'd also like to convert " to \" and
      \ to \\.
     </A
></DT
><DT
>3. <A
HREF="faq.using.html#faq.using.stripslashes"
>&#13;      All my " turn into \" and my ' turn into \', how do I get rid of all 
      these unwanted backslashes?  How and why did they get there?
     </A
></DT
><DT
>4. <A
HREF="faq.using.html#faq.using.wrong-order"
>&#13;      When I do the following, the output is printed in 
      the wrong order: 
     <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">function </font><font color="#0000BB">myfunc</font><font color="#007700">(</font><font color="#0000BB">$argument</font><font color="#007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#0000BB">$argument </font><font color="#007700">+ </font><font color="#0000BB">10</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">$variable </font><font color="#007700">= </font><font color="#0000BB">10</font><font color="#007700">;<br />echo </font><font color="#DD0000">"myfunc($variable) = " </font><font color="#007700">. </font><font color="#0000BB">myfunc</font><font color="#007700">(</font><font color="#0000BB">$variable</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
>
     what's going on?
     </A
></DT
><DT
>5. <A
HREF="faq.using.html#faq.using.newlines"
>&#13;      Hey, what happened to my newlines?
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
&lt;pre&gt;<br /><font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"This should be the first line."</font><font color="#007700">; </font><font color="#0000BB">?&gt;<br />&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"This should show up after the new line above."</font><font color="#007700">; </font><font color="#0000BB">?&gt;<br /></font>&lt;/pre&gt;</font>
</code></TD
></TR
></TABLE
>
     </A
></DT
><DT
>6. <A
HREF="faq.using.html#faq.using.headers-sent"
>&#13;      I get the message 'Warning: Cannot send session cookie - headers already
      sent...' or 'Cannot add header information - headers already sent...'.
     </A
></DT
><DT
>7. <A
HREF="faq.using.html#faq.using.header"
>&#13;      I need to access information in the request header directly. 
      How can I do this?
     </A
></DT
><DT
>8. <A
HREF="faq.using.html#faq.using.authentication"
>&#13;      When I try to use authentication with IIS I get 'No Input file specified'.
     </A
></DT
><DT
>9. <A
HREF="faq.using.html#faq.using.iis.sharing"
>&#13;      Windows: I can't access files shared on another computer using IIS
     </A
></DT
><DT
>10. <A
HREF="faq.using.html#faq.using.netscape"
>&#13;      My PHP script works on IE and Lynx, but on Netscape some of
      my output is missing. When I do a "View Source" I see the 
      content in IE but not in Netscape.
     </A
></DT
><DT
>11. <A
HREF="faq.using.html#faq.using.mixml"
>&#13;      How am I supposed to mix XML and PHP? It complains 
      about my &#60;?xml tags!
     </A
></DT
><DT
>12. <A
HREF="faq.using.html#faq.using.editor"
>&#13;      How can I use PHP with FrontPage or some other HTML editor
      that insists on moving my code around?
     </A
></DT
><DT
>13. <A
HREF="faq.using.html#faq.using.variables"
>&#13;      Where can I find a complete list of variables are available to me 
      in PHP?
     </A
></DT
><DT
>14. <A
HREF="faq.using.html#faq.using.freepdf"
>&#13;      How can I generate PDF files without using the non-free and 
      commercial libraries <A
HREF="ref.cpdf.html"
>ClibPDF</A
> and 
      <A
HREF="ref.pdf.html"
>PDFLib</A
>?  I'd like something that's 
      free and doesn't require external PDF libraries.
     </A
></DT
><DT
>15. <A
HREF="faq.using.html#faq.using.cgi-vars"
>&#13;      I'm trying to access one of the standard CGI
      variables (such as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined
      function, and it can't seem to find it. What's wrong?
     </A
></DT
><DT
>16. <A
HREF="faq.using.html#faq.using.shorthandbytes"
>&#13;      A few PHP directives may also take on shorthand byte values, as opposed
      to only <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
> byte values.  What are all the available
      shorthand byte options?  And can I use these outside of <TT
CLASS="filename"
>php.ini</TT
>?
     </A
></DT
></DL
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.anyform"
></A
><B
>1. </B
>
      I would like to write a generic PHP script that can handle data coming 
      from any form. How do I know which POST method variables are available?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      PHP offers many <A
HREF="language.variables.predefined.html"
>&#13;      predefined variables</A
>, like the superglobal <CODE
CLASS="varname"
>&#13;      $_POST</CODE
>.  You may loop through <CODE
CLASS="varname"
>$_POST</CODE
>
      as it's an associate array of all POSTed values.  For example, let's
      simply loop through it with <A
HREF="control-structures.foreach.html"
>&#13;      foreach</A
>, check for <A
HREF="function.empty.html"
><B
CLASS="function"
>empty()</B
></A
> values,
      and print them out.
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$empty </font><font color="#007700">= </font><font color="#0000BB">$post </font><font color="#007700">= array();<br />foreach (</font><font color="#0000BB">$_POST </font><font color="#007700">as </font><font color="#0000BB">$varname </font><font color="#007700">=&gt; </font><font color="#0000BB">$varvalue</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;if (empty(</font><font color="#0000BB">$varvalue</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$empty</font><font color="#007700">[</font><font color="#0000BB">$varname</font><font color="#007700">] = </font><font color="#0000BB">$varvalue</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$post</font><font color="#007700">[</font><font color="#0000BB">$varname</font><font color="#007700">] = </font><font color="#0000BB">$varvalue</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />print </font><font color="#DD0000">"&lt;pre&gt;"</font><font color="#007700">;<br />if (empty(</font><font color="#0000BB">$empty</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"None of the POSTed values are empty, posted:\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$post</font><font color="#007700">);<br />} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"We have " </font><font color="#007700">. </font><font color="#0000BB">count</font><font color="#007700">(</font><font color="#0000BB">$empty</font><font color="#007700">) . </font><font color="#DD0000">" empty values\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"Posted:\n"</font><font color="#007700">; </font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$post</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"Empty:\n"</font><font color="#007700">;&nbsp;&nbsp;</font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$empty</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
>
     </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Disponibilidade das superglobais:: </B
>Desde o PHP 4.1.0, os arrays superglobais como <CODE
CLASS="varname"
>$_GET
 </CODE
>, <CODE
CLASS="varname"
>$_POST</CODE
>, <CODE
CLASS="varname"
>$_SERVER</CODE
>,
 etc. sempre estão carregados. Para mais informações, leia a seção do manual
 sobre <A
HREF="language.variables.predefined.html"
>superglobals</A
></P
></BLOCKQUOTE
></DIV
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.addslashes"
></A
><B
>2. </B
>
      I need to convert all single-quotes (') to a backslash 
      followed by a single-quote (\'). How can I do this with a 
      regular expression?  I'd also like to convert " to \" and
      \ to \\.
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      The function <A
HREF="function.addslashes.html"
><B
CLASS="function"
>addslashes()</B
></A
> will do this.  See
      also <A
HREF="function.mysql-escape-string.html"
><B
CLASS="function"
>mysql_escape_string()</B
></A
>.  You may also
      strip backslashes with <A
HREF="function.stripslashes.html"
><B
CLASS="function"
>stripslashes()</B
></A
>.
     </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota sobre a diretiva magic_quotes_gpc:: </B
>A diretiva do PHP <A
HREF="ref.info.html#ini.magic-quotes-gpc"
>&#13; magic_quotes_gpc</A
> tem default <TT
CLASS="literal"
>on</TT
>. Ela essencialmente
 roda <A
HREF="function.addslashes.html"
><B
CLASS="function"
>addslashes()</B
></A
> em todos os dados postados por GET, POST e COOKIEs.
 Você pode utilizar <A
HREF="function.stripslashes.html"
><B
CLASS="function"
>stripslashes()</B
></A
> para reverter isso.</P
></BLOCKQUOTE
></DIV
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.stripslashes"
></A
><B
>3. </B
>
      All my " turn into \" and my ' turn into \', how do I get rid of all 
      these unwanted backslashes?  How and why did they get there?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      The PHP function <A
HREF="function.stripslashes.html"
><B
CLASS="function"
>stripslashes()</B
></A
> will strip those
      backslashes from your <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>.  Most likely the backslashes 
      magically exist because the PHP directive 
      <A
HREF="ref.info.html#ini.magic-quotes-gpc"
>magic_quotes_gpc</A
> is on.
     </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota sobre a diretiva magic_quotes_gpc:: </B
>A diretiva do PHP <A
HREF="ref.info.html#ini.magic-quotes-gpc"
>&#13; magic_quotes_gpc</A
> tem default <TT
CLASS="literal"
>on</TT
>. Ela essencialmente
 roda <A
HREF="function.addslashes.html"
><B
CLASS="function"
>addslashes()</B
></A
> em todos os dados postados por GET, POST e COOKIEs.
 Você pode utilizar <A
HREF="function.stripslashes.html"
><B
CLASS="function"
>stripslashes()</B
></A
> para reverter isso.</P
></BLOCKQUOTE
></DIV
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.wrong-order"
></A
><B
>4. </B
>
      When I do the following, the output is printed in 
      the wrong order: 
     <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">function </font><font color="#0000BB">myfunc</font><font color="#007700">(</font><font color="#0000BB">$argument</font><font color="#007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#0000BB">$argument </font><font color="#007700">+ </font><font color="#0000BB">10</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">$variable </font><font color="#007700">= </font><font color="#0000BB">10</font><font color="#007700">;<br />echo </font><font color="#DD0000">"myfunc($variable) = " </font><font color="#007700">. </font><font color="#0000BB">myfunc</font><font color="#007700">(</font><font color="#0000BB">$variable</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
>
     what's going on?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      To be able to use the results of your function in an expression (such
      as concatenating it with other strings in the example above), you need
      to <A
HREF="function.return.html"
><B
CLASS="function"
>return()</B
></A
> the value, not <A
HREF="function.echo.html"
><B
CLASS="function"
>echo()</B
></A
> 
      it.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.newlines"
></A
><B
>5. </B
>
      Hey, what happened to my newlines?
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
&lt;pre&gt;<br /><font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"This should be the first line."</font><font color="#007700">; </font><font color="#0000BB">?&gt;<br />&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"This should show up after the new line above."</font><font color="#007700">; </font><font color="#0000BB">?&gt;<br /></font>&lt;/pre&gt;</font>
</code></TD
></TR
></TABLE
>
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      In PHP, the ending for a block of code is either "?&#62;" or
      "?&#62;\n" (where \n means a newline). So in the example above,
      the echoed sentences will be on one line, because PHP omits
      the newlines after the block ending. This means that you need to
      insert an extra newline after each block of PHP code to make
      it print out one newline.
     </P
><P
>&#13;      Why does PHP do this? Because when formatting normal HTML, this
      usually makes your life easier because you don't want that newline,
      but you'd have to create extremely long lines or otherwise make the
      raw page source unreadable to achieve that effect.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.headers-sent"
></A
><B
>6. </B
>
      I get the message 'Warning: Cannot send session cookie - headers already
      sent...' or 'Cannot add header information - headers already sent...'.
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      The functions <A
HREF="function.header.html"
><B
CLASS="function"
>header()</B
></A
>, <A
HREF="function.setcookie.html"
><B
CLASS="function"
>setcookie()</B
></A
>,
      and the <A
HREF="ref.session.html"
>session 
      functions</A
> need to add headers to the output stream but headers 
      can only be sent before all other content.  There can be no output
      before using these functions, output such as HTML.  The function <B
CLASS="function"
>&#13;      headers_sent()</B
> will check if your script has already sent 
      headers and see also the <A
HREF="ref.outcontrol.html"
>Output Control
      functions</A
>.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.header"
></A
><B
>7. </B
>
      I need to access information in the request header directly. 
      How can I do this?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      The <A
HREF="function.getallheaders.html"
><B
CLASS="function"
>getallheaders()</B
></A
> function will do this if 
      you are running PHP as an Apache module. So, the following bit
      of code will show you all the request headers:
      <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$headers </font><font color="#007700">= </font><font color="#0000BB">getallheaders</font><font color="#007700">();<br />foreach (</font><font color="#0000BB">$headers </font><font color="#007700">as </font><font color="#0000BB">$name </font><font color="#007700">=&gt; </font><font color="#0000BB">$content</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"headers</font><font color="#007700">[</font><font color="#DD0000">$name</font><font color="#007700">]</font><font color="#DD0000"> = $content&lt;br /&gt;</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
>
     </P
><P
>&#13;      See also 
      <A
HREF="function.apache-lookup-uri.html"
><B
CLASS="function"
>apache_lookup_uri()</B
></A
>,
      <A
HREF="function.apache-response-headers.html"
><B
CLASS="function"
>apache_response_headers()</B
></A
>, and
      <A
HREF="function.fsockopen.html"
><B
CLASS="function"
>fsockopen()</B
></A
>
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.authentication"
></A
><B
>8. </B
>
      When I try to use authentication with IIS I get 'No Input file specified'.
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      The security model of IIS is at fault here. This is a problem
      common to all CGI programs running under IIS. A workaround is
      to create a plain HTML file (not parsed by PHP) as the entry page
      into an authenticated directory. Then use a META tag to redirect
      to the PHP page, or have a link to the PHP page. PHP will
      then recognize the authentication correctly. With the ISAPI
      module, this is not a problem. This should not effect other
      NT web servers. For more information, see: 
      <A
HREF="http://support.microsoft.com/kb/q160422/"
TARGET="_top"
>http://support.microsoft.com/kb/q160422/</A
> and the manual
      section on <A
HREF="features.http-auth.html"
>HTTP Authentication
      </A
>.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.iis.sharing"
></A
><B
>9. </B
>
      Windows: I can't access files shared on another computer using IIS
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      You have to change the <TT
CLASS="literal"
>Go to Internet Information
      Services</TT
>. Locate your PHP file and go to its properties.
      Go to the <TT
CLASS="literal"
>File Security</TT
> tab, <TT
CLASS="literal"
>Edit -&#60; 
      Anonymous access and authentication control</TT
>.
     </P
><P
>&#13;      You can fix the problem either by unticking <TT
CLASS="literal"
>Anonymous
      Access</TT
> and leaving <TT
CLASS="literal"
>Integrated Window
      Authentication</TT
> ticked, or, by ticking <TT
CLASS="literal"
>Anonymous
      Access</TT
> and editing the user as he may not have the access
      right. 
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.netscape"
></A
><B
>10. </B
>
      My PHP script works on IE and Lynx, but on Netscape some of
      my output is missing. When I do a "View Source" I see the 
      content in IE but not in Netscape.
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Netscape is more strict regarding HTML tags (such as tables) then 
      IE.  Running your HTML output through a HTML validator, such as 
      <A
HREF="http://validator.w3.org/"
TARGET="_top"
>validator.w3.org</A
>, might 
      be helpful.  For example, a missing &#60;/table&#62; might cause this.
     </P
><P
>&#13;      Also, both IE and Lynx ignore any NULs (<TT
CLASS="literal"
>\0</TT
>) in 
      the HTML stream, Netscape does not.  The best way to check for this is 
      to compile the <A
HREF="features.commandline.html"
>command line</A
> version of 
      PHP (also known as the CGI version) and run your script from the
      command line.  In *nix, pipe it through <TT
CLASS="literal"
>od -c</TT
> and look 
      for any <TT
CLASS="literal"
>\0</TT
> characters.  If you are on Windows you need 
      to find an editor or some other program that lets you look at binary files.  
      When Netscape sees a NUL in a file it will typically not output anything 
      else on that line whereas both IE and Lynx will. 
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.mixml"
></A
><B
>11. </B
>
      How am I supposed to mix XML and PHP? It complains 
      about my &#60;?xml tags!
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      In order to embed &#60;?xml straight into your PHP code, you'll have to turn off
      short tags by having the PHP directive 
      <A
HREF="ini.core.html#ini.short-open-tag"
>short_open_tags</A
> set to 
      <TT
CLASS="literal"
>0</TT
>.  You cannot set this directive with <B
CLASS="function"
>&#13;      ini_set()</B
>.  Regardless of <A
HREF="ini.core.html#ini.short-open-tag"
>&#13;      short_open_tags</A
> being on or off, you can do something like:
      <TT
CLASS="literal"
>&#60;?php echo '&#60;?xml'; ?&#62;</TT
>.  The default
      for this directive is on.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.editor"
></A
><B
>12. </B
>
      How can I use PHP with FrontPage or some other HTML editor
      that insists on moving my code around?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      One of the easiest things to do is to enable using ASP tags in your
      PHP code. This allows you to use the ASP-style &#60;% and %&#62; code
      delimiters. Some of the popular HTML editors handle those more
      intelligently (for now). To enable the ASP-style tags, you need
      to set the <A
HREF="ini.core.html#ini.asp-tags"
>asp_tags</A
>
      <TT
CLASS="filename"
>php.ini</TT
> variable, or use the 
      appropriate Apache directive.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.variables"
></A
><B
>13. </B
>
      Where can I find a complete list of variables are available to me 
      in PHP?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Read the manual page on <A
HREF="language.variables.predefined.html"
>&#13;      predefined variables</A
> as it includes a partial list of predefined
      variables available to your script.  A complete list of available
      variables (and much more information) can be seen by calling the 
      <A
HREF="function.phpinfo.html"
><B
CLASS="function"
>phpinfo()</B
></A
> function.  Be sure to read the manual 
      section on <A
HREF="language.variables.external.html"
>variables from 
      outside of PHP</A
> as it describes common scenarios for 
      external variables, like from a HTML form, a Cookie, and the URL.
     </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota importante sobre register_globals:: </B
>Desde o PHP 4.2.0, o valor padrão para a diretiva
 <A
HREF="ini.core.html#ini.register-globals"
>register_globals</A
> é <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>&#13; off</I
></SPAN
> e foi completamente removida a partir do PHP 6.0.0. A comunidade do PHP
 encoraja a todos a não depender desta configuração mas ao invés usar outros meios,
 como, por exemplo, <A
HREF="language.variables.predefined.html"
>superglobals</A
>.
 </P
></BLOCKQUOTE
></DIV
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.freepdf"
></A
><B
>14. </B
>
      How can I generate PDF files without using the non-free and 
      commercial libraries <A
HREF="ref.cpdf.html"
>ClibPDF</A
> and 
      <A
HREF="ref.pdf.html"
>PDFLib</A
>?  I'd like something that's 
      free and doesn't require external PDF libraries.
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      There are a few alternatives written in PHP such as 
      <A
HREF="http://www.ros.co.nz/pdf/"
TARGET="_top"
>http://www.ros.co.nz/pdf/</A
>, 
      <A
HREF="http://www.fpdf.org/"
TARGET="_top"
>http://www.fpdf.org/</A
>, 
      <A
HREF="http://www.gnuvox.com/pdf4php/"
TARGET="_top"
>http://www.gnuvox.com/pdf4php/</A
>, and 
      <A
HREF="http://www.potentialtech.com/ppl.php"
TARGET="_top"
>http://www.potentialtech.com/ppl.php</A
>.
      There is also the <A
HREF="http://www.stillhq.com/cgi-bin/getpage?area=panda"
TARGET="_top"
>Panda</A
> module.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.cgi-vars"
></A
><B
>15. </B
>
      I'm trying to access one of the standard CGI
      variables (such as $DOCUMENT_ROOT or $HTTP_REFERER) in a user-defined
      function, and it can't seem to find it. What's wrong?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      It's important to realize that the PHP directive <A
HREF="ini.core.html#ini.register-globals"
>register_globals</A
> also affects
      server and environment variables.  When register_globals = off (the
      default is off since PHP 4.2.0), <CODE
CLASS="varname"
>$DOCUMENT_ROOT</CODE
>
      will not exist. Instead, use <CODE
CLASS="varname"
>$_SERVER['DOCUMENT_ROOT']
      </CODE
>.  If register_globals = on then the variables
      <CODE
CLASS="varname"
>$DOCUMENT_ROOT</CODE
> and
      <CODE
CLASS="varname"
>$GLOBALS['DOCUMENT_ROOT']</CODE
> will also exist.
     </P
><P
>&#13;      If you're sure register_globals = on and wonder why
      <CODE
CLASS="varname"
>$DOCUMENT_ROOT</CODE
> isn't available inside functions,
      it's because these are like any other variables and would 
      require <TT
CLASS="literal"
>global $DOCUMENT_ROOT</TT
> inside the
      function.  See also the manual page on 
      <A
HREF="language.variables.scope.html"
>variable scope</A
>.  It's
      preferred to code with register_globals = off.
     </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Disponibilidade das superglobais:: </B
>Desde o PHP 4.1.0, os arrays superglobais como <CODE
CLASS="varname"
>$_GET
 </CODE
>, <CODE
CLASS="varname"
>$_POST</CODE
>, <CODE
CLASS="varname"
>$_SERVER</CODE
>,
 etc. sempre estão carregados. Para mais informações, leia a seção do manual
 sobre <A
HREF="language.variables.predefined.html"
>superglobals</A
></P
></BLOCKQUOTE
></DIV
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.using.shorthandbytes"
></A
><B
>16. </B
>
      A few PHP directives may also take on shorthand byte values, as opposed
      to only <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
> byte values.  What are all the available
      shorthand byte options?  And can I use these outside of <TT
CLASS="filename"
>php.ini</TT
>?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      The available options are K (for Kilobytes), M (for Megabytes) and G (for
      Gigabytes; available since PHP 5.1.0), these are case insensitive.
      Anything else assumes bytes.
      <TT
CLASS="literal"
>1M</TT
> equals one Megabyte or <TT
CLASS="literal"
>1048576</TT
>
      bytes.  <TT
CLASS="literal"
>1K</TT
> equals one Kilobyte or 
      <TT
CLASS="literal"
>1024</TT
> bytes.  You may not use these shorthand 
      notations outside of <TT
CLASS="filename"
>php.ini</TT
>, instead use an <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
> 
      value of bytes.  See the <A
HREF="function.ini-get.html"
><B
CLASS="function"
>ini_get()</B
></A
> documentation for
      an example on how to convert these values.
     </P
></DIV
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="faq.build.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="faq.html.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Build Problems</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="faq.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>PHP and HTML</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>