Sophie

Sophie

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

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
>PHP e COM</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="PHP and HTML"
HREF="faq.html.html"><LINK
REL="NEXT"
TITLE="PHP e outras linguagens"
HREF="faq.languages.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.html.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="faq.languages.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="faq.com"
>Capítulo 57. PHP e COM</A
></H1
><P
>&#13;    PHP pode ser usado para acessar objetos COM e DCOM em plataformas Win32.
   </P
><DIV
CLASS="qandaset"
><DL
><DT
>1. <A
HREF="faq.com.html#faq.com.q1"
>&#13;      Eu construi uma DLL para calcular algo. Existe uma maneira de executar essa DLL no PHP ?
     </A
></DT
><DT
>2. <A
HREF="faq.com.html#faq.com.q2"
>&#13;      O que 'Unsupported variant type: xxxx (0xxxxx)' significa ?
     </A
></DT
><DT
>3. <A
HREF="faq.com.html#faq.com.q3"
>&#13;      É possível manipular objetos visuais no PHP ?
     </A
></DT
><DT
>4. <A
HREF="faq.com.html#faq.com.q4"
>&#13;      Posso guardar um objeto COM em uma sessão ?
     </A
></DT
><DT
>5. <A
HREF="faq.com.html#faq.com.q5"
>&#13;      Como eu trato erros de COM ?
     </A
></DT
><DT
>6. <A
HREF="faq.com.html#faq.com.q6"
>&#13;      Posso gerar arquivos DLL de scripts PHP como eu posso no Perl ?
     </A
></DT
><DT
>7. <A
HREF="faq.com.html#faq.com.q7"
>&#13;      O que significa 'Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}' ?
     </A
></DT
><DT
>8. <A
HREF="faq.com.html#faq.com.q8"
>&#13;      Como posso executar um objeto COM de um servidor remoto ?
     </A
></DT
><DT
>9. <A
HREF="faq.com.html#faq.com.q9"
>&#13;      Eu vejo o erro 'DCOM is disabled in C:\path...\scriptname.php on line 6', o que posso fazer ?
     </A
></DT
><DT
>10. <A
HREF="faq.com.html#faq.com.q10"
>&#13;      É possível carregar/manipular um objeto ActiveX em uma página com o PHP ?
     </A
></DT
><DT
>11. <A
HREF="faq.com.html#faq.com.q11"
>&#13;      É possível pegar uma instância sendo executada de um componente ?
     </A
></DT
><DT
>12. <A
HREF="faq.com.html#faq.com.q12"
>&#13;      Existe alguma maneria de lidar com um evento enviado pode um objeto COM ?
     </A
></DT
><DT
>13. <A
HREF="faq.com.html#faq.com.q13"
>&#13;      Estou tendo problemas quando tento invocar um método de um objeto COM
      que expõe mais de uma interface. O que posso fazer ?
     </A
></DT
><DT
>14. <A
HREF="faq.com.html#faq.com.q14"
>&#13;      Então PHP funciona com COM, e com COM+ ?
     </A
></DT
><DT
>15. <A
HREF="faq.com.html#faq.com.q15"
>&#13;      Se o PHP pode manipular objetos COM, podemos imaginar usar
      MTS para administrar recursos de componentes, em conjunção com PHP ?
     </A
></DT
></DL
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q1"
></A
><B
>1. </B
>
      Eu construi uma DLL para calcular algo. Existe uma maneira de executar essa DLL no PHP ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Se for uma DLL simples, ainda não tem como executá-la no PHP. Se a DLL contem um serviço
      COM você pode acessá-lo se ele implementar a interface IDispatch.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q2"
></A
><B
>2. </B
>
      O que 'Unsupported variant type: xxxx (0xxxxx)' significa ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Existem dezenas de tipos VARIANT e combinações dos mesmos. A maioria deles já são suportados mas
      alguns ainda tem que ser implementados.
      Arrays não são completamente suportados. Apenas arrays indexados com
      uma única dimensão podem ser passados entre o PHP e COM.
      Se você achar outros tipos que não são suportados, por favor relate-os como um bug (se não tiverem sido relatados ainda)
      e passe o máximo de informação disponível.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q3"
></A
><B
>3. </B
>
      É possível manipular objetos visuais no PHP ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Geralmente é, mas como o PHP é principalmente usado como linguagem de script pra web, ele é executado no contexto dos servidores web, então
      objetos visuais nunca aparecerão no desktop do servidor.
      Se você usa o PHP para script de aplicações, ex.: em conjunto com PHP-GTK não há limitação no acesso e
      manipulação de objetos visuais através de COM.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q4"
></A
><B
>4. </B
>
      Posso guardar um objeto COM em uma sessão ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Não, não pode. Instâncias COM são tratadas como recursos (resources) e, portanto, só estão disponíveis no contexto de um script único.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q5"
></A
><B
>5. </B
>
      Como eu trato erros de COM ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      No PHP 5, a extensão COM dispara exceções do tipo
      <TT
CLASS="literal"
>com_exception</TT
>, que você pode pegar e então inspecionar o
      membro <TT
CLASS="literal"
>code</TT
> para determinar o que fazer depois.
     </P
><P
>&#13;      No PHP 4 não é possível pegar erros de COM a não ser pelas maneiras providas pelo próprio PHP (@, track_errors, ..).
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q6"
></A
><B
>6. </B
>
      Posso gerar arquivos DLL de scripts PHP como eu posso no Perl ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Não, infelizmente não existe tal ferramenta disponível para o PHP.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q7"
></A
><B
>7. </B
>
      O que significa 'Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}' ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Esse erro pode ter várias razões:
      <P
></P
><UL
><LI
><P
>&#13;         o CLSID está errado
         </P
></LI
><LI
><P
>&#13;         a DLL requisitada não existe ou não pode ser lida
         </P
></LI
><LI
><P
>&#13;         o componente requisitado não implementa a interface IDispatch
         </P
></LI
></UL
>
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q8"
></A
><B
>8. </B
>
      Como posso executar um objeto COM de um servidor remoto ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Exatamente como você executa objetos locais. Você só tem que passar o IP da máquina remota como segundo parâmetro para
      o construtor COM.
     </P
><P
>&#13;      Assegure-se que você editou <A
HREF="ref.com.html#ini.com.allow-dcom"
><I
CLASS="term"
>&#13;     <CODE
CLASS="parameter"
>com.allow_dcom</CODE
>
    </I
></A
> para <TT
CLASS="literal"
>=<TT
CLASS="constant"
><B
>TRUE</B
></TT
></TT
> no seu arquivo <TT
CLASS="filename"
>php.ini</TT
>.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q9"
></A
><B
>9. </B
>
      Eu vejo o erro 'DCOM is disabled in C:\path...\scriptname.php on line 6', o que posso fazer ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Edite seu arquivo <TT
CLASS="filename"
>php.ini</TT
> e edite <A
HREF="ref.com.html#ini.com.allow-dcom"
><I
CLASS="term"
>&#13;     <CODE
CLASS="parameter"
>com.allow_dcom</CODE
>
    </I
></A
> para <TT
CLASS="literal"
>=<TT
CLASS="constant"
><B
>TRUE</B
></TT
></TT
>.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q10"
></A
><B
>10. </B
>
      É possível carregar/manipular um objeto ActiveX em uma página com o PHP ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Isso não tem nada a ver com o PHP. Objetos ActiveX são carregados no lado do cliente se eles forem requisitados
      pelo documento HTML. Não há relação com o script PHP e, portanto, nenhuma interação
      direta possível com o lado do servidor.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q11"
></A
><B
>11. </B
>
      É possível pegar uma instância sendo executada de um componente ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      É possível com a ajuda de monikers. Se você quiser referências múltiplas para a mesma instância
      você pode criar uma instância como mostrado abaixo:
     </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$word </font><font color="#007700">= new </font><font color="#0000BB">COM</font><font color="#007700">(</font><font color="#DD0000">"C:\docs\word.doc"</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;      Isso criará uma nova instância se nenhuma instância sendo executada estiver disponível e retornará um handle para a
      ela, se disponível.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q12"
></A
><B
>12. </B
>
      Existe alguma maneria de lidar com um evento enviado pode um objeto COM ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      Você pode definir um interceptador de eventos usando
      <A
HREF="function.com-event-sink.html"
><B
CLASS="function"
>com_event_sink()</B
></A
>.  Você pode usar
      <A
HREF="function.com-print-typeinfo.html"
><B
CLASS="function"
>com_print_typeinfo()</B
></A
> para que o PHP gere um esqueleto
      para a classe interceptadora de eventos.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q13"
></A
><B
>13. </B
>
      Estou tendo problemas quando tento invocar um método de um objeto COM
      que expõe mais de uma interface. O que posso fazer ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      A resposta é tão simples quanto insatisfatória. Eu não sei exatamente, mas acho que não há nada a fazer.
      Se alguém tem informação específica sobre isso, por favor <A
HREF="mailto:harald.radi@nme.at"
TARGET="_top"
>me</A
> avise (mande e-mails em inglês) :)
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q14"
></A
><B
>14. </B
>
      Então PHP funciona com COM, e com COM+ ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      COM+ é COM mais uma framework para manusear componentes através de MTS e MSMQ mas não há nada especial
      que o PHP tenha suporte ao uso de tais componentes.
     </P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><B
><DIV
CLASS="question"
><P
><A
NAME="faq.com.q15"
></A
><B
>15. </B
>
      Se o PHP pode manipular objetos COM, podemos imaginar usar
      MTS para administrar recursos de componentes, em conjunção com PHP ?
     </P
></DIV
></B
><DIV
CLASS="answer"
><P
><B
> </B
>
      O PHP em si não lida com transações ainda. Por isso, se um erro
      ocorre, nenhum rollback é iniciado. Se você usar componentes que
      suportem transações você pode implementar a
      administração de transações por conta própria.
     </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.html.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.languages.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>PHP and HTML</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 e outras linguagens</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>