JoaoNascimento Posted February 21, 2012 at 05:55 PM Report Share #440582 Posted February 21, 2012 at 05:55 PM Pessoal estou com uma grande duvida. Como chamo uma função de php no html. Já tentei o <?php funcao()?> mas não consegui. http://www.joaonascimento.info Link to comment Share on other sites More sharing options...
yoda Posted February 21, 2012 at 05:56 PM Report Share #440583 Posted February 21, 2012 at 05:56 PM Se o ficheiro tiver html como extensão não consegues. before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
JoaoNascimento Posted February 21, 2012 at 06:01 PM Author Report Share #440584 Posted February 21, 2012 at 06:01 PM Por acaso também tem extensão php http://www.joaonascimento.info Link to comment Share on other sites More sharing options...
yoda Posted February 21, 2012 at 06:32 PM Report Share #440586 Posted February 21, 2012 at 06:32 PM <?php funcao(); ?> before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
JoaoNascimento Posted February 21, 2012 at 06:37 PM Author Report Share #440587 Posted February 21, 2012 at 06:37 PM Pois então pelo que estou a ver o problema não é de como chamar a função mas sim o contexto em que ela é chamada. http://www.joaonascimento.info Link to comment Share on other sites More sharing options...
charly Posted February 21, 2012 at 06:44 PM Report Share #440588 Posted February 21, 2012 at 06:44 PM tens a certeza que o alojamento suporta php-script? Link to comment Share on other sites More sharing options...
yoda Posted February 21, 2012 at 07:01 PM Report Share #440590 Posted February 21, 2012 at 07:01 PM A função convém que esteja registada no escopo global. Pode estar em ficheiros diferentes desde que o ficheiro em causa tenha acesso aos outros por inclusão. Se a função estiver registada no escopo de um objecto ou array necessita que essas instâncias estejam disponíveis também no escopo geral. Podes também, a partir do PHP 5.3 usar funções anónimas : <?php $funcao = function() { echo 'teste'; } ?> <div><?php $funcao; ?></div> before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
JoaoNascimento Posted February 21, 2012 at 07:22 PM Author Report Share #440598 Posted February 21, 2012 at 07:22 PM tens a certeza que o alojamento suporta php-script? Estou a trabalhar em localhost com o Xampp http://www.joaonascimento.info Link to comment Share on other sites More sharing options...
yoda Posted February 21, 2012 at 07:33 PM Report Share #440601 Posted February 21, 2012 at 07:33 PM E os serviços PHP e Apache está a correr em condições? Abre o icon do xampp no system tray e confirma. before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
amando96 Posted February 27, 2012 at 10:28 PM Report Share #441408 Posted February 27, 2012 at 10:28 PM Que função é? se a função só devolver resultados tens que <?php echo funcao(); ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now