Sunday, February 3, 2013

Your first PHP-enabled page

Create a file named hello.php and put it in your web server's root directory (DOCUMENT_ROOT) with the following content:

Example #1 Our first PHP script: hello.php
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<p>Hello World</p>'?>
 </body>
</html>
Use your browser to access the file with your web server's URL, ending with the /hello.php file reference. When developing locally this URL will be something like http://localhost/hello.php or http://127.0.0.1/hello.php but this depends on the web server's configuration. If everything is configured correctly, this file will be parsed by PHP and the following output will be sent to your browser:
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <p>Hello World</p>
 </body>
</html>

This program is extremely simple and you really did not need to use PHP to create a page like this. All it does is display: Hello World using the PHP echostatement. Note that the file does not need to be executable or special in any way. The server finds out that this file needs to be interpreted by PHP because you used the ".php" extension, which the server is configured to pass on to PHP. Think of this as a normal HTML file which happens to have a set of special tags available to you that do a lot of interesting things.
If you tried this example and it did not output anything, it prompted for download, or you see the whole file as text, chances are that the server you are on does not have PHP enabled, or is not configured properly. Ask your administrator to enable it for you using the Installation chapter of the manual. If you are developing locally, also read the installation chapter to make sure everything is configured properly. Make sure that you access the file via http with the server providing you the output. If you just call up the file from your file system, then it will not be parsed by PHP. If the problems persist anyway, do not hesitate to use one of the many » PHP support options.
The point of the example is to show the special PHP tag format. In this example we used <?php to indicate the start of a PHP tag. Then we put the PHP statement and left PHP mode by adding the closing tag, ?>. You may jump in and out of PHP mode in an HTML file like this anywhere you want. For more details, read the manual section on the basic PHP syntax.
NoteA Note on Line Feeds
Line feeds have little meaning in HTML, however it is still a good idea to make your HTML look nice and clean by putting line feeds in. A linefeed that follows immediately after a closing ?> will be removed by PHP. This can be extremely useful when you are putting in many blocks of PHP or include files containing PHP that aren't supposed to output anything. At the same time it can be a bit confusing. You can put a space after the closing ?> to force a space and a line feed to be output, or you can put an explicit line feed in the last echo/print from within your PHP block.
NoteA Note on Text Editors
There are many text editors and Integrated Development Environments (IDEs) that you can use to create, edit and manage PHP files. A partial list of these tools is maintained at » PHP Editors List. If you wish to recommend an editor, please visit the above page and ask the page maintainer to add the editor to the list. Having an editor with syntax highlighting can be helpful.
NoteA Note on Word Processors
Word processors such as StarOffice Writer, Microsoft Word and Abiword are not optimal for editing PHP files. If you wish to use one for this test script, you must ensure that you save the file as plain text or PHP will not be able to read and execute the script.
NoteA Note on Windows Notepad
If you are writing your PHP scripts using Windows Notepad, you will need to ensure that your files are saved with the .php extension. (Notepad adds a .txtextension to files automatically unless you take one of the following steps to prevent it.) When you save the file and are prompted to provide a name for the file, place the filename in quotes (i.e. "hello.php"). Alternatively, you can click on the 'Text Documents' drop-down menu in the 'Save' dialog box and change the setting to "All Files". You can then enter your filename without quotes.
Now that you have successfully created a working PHP script, it is time to create the most famous PHP script! Make a call to the phpinfo() function and you will see a lot of useful information about your system and setup such as available predefined variables, loaded PHP modules, and configuration settings. Take some time and review this important information.
Example #2 Get system information from PHP
<?php phpinfo(); ?>

2 comments:

  1. interested content i like that. keep it up!
    visit horny page now http://www.hornypage.blogspot.com

    ReplyDelete
  2. AS OPORTUNIDADES APARECEM QUANDO VOCÊ MENOS ESPERA!



    CADASTRE-SE JÁ E FAÇA PARTE DE ALGO GRANDIOSO! O CADASTRO ATÉ A DATA DO LANÇAMENTO É GRATUITO E BEM SIMPLES DE SE FAZE!
    Marketing Multinível, ou MMN, é uma forma de distribuição ou marketing baseada no trabalho de equipe, na qual cada participante é convidado a integrar uma equipe existente e estimulado a liderar a sua própria a partir daí, ajudando a sua rede a crescer e sendo recompensado por isso.

    Em geral, as pessoas que conseguem melhores resultados no Marketing Multinível são aquelas que acreditam na oportunidade mesmo em meio às incertezas. Por quê? Porque enquanto os outros perdem o tempo com dúvidas, eles estão oferecendo bons negócios aos seus amigos, familiares e conhecidos, construindo sua rede de contatos, com um mercado amplo a conquistar e centenas ou milhares de pessoas interessadas em fazer parte de sua equipe.

    Por esta razão, acreditando que este é um que se destacará entre vários bons negócios disponíveis da internet, estamos divulgando a oportunidade do World Prelaunch.

    A iniciativa deste negócio de construir sua rede de contatos antes do multinível começar a funcionar é fantástica!

    Já sabemos que é um negócio legítimo, que trabalhará com vendas diretas e já está registrado junto à DSA (Direct Selling Association), conferindo cada vez mais credibilidade à oportunidade. Temos certeza que, por nos estimular a formar as redes antes de seu funcionamento efetivo, o World Prelaunch será uma oportunidade incrível de ganhar dinheiro online.

    Cadastre-se hoje gratuitamente e garanta uma boa colocação antes mesmo do lançamento mundial!

    Não se preocupe, a oferta definitiva será apresentada dia 18 de março de 2013, quando nós todos confirmaremos a nossa participação no projeto!

    World Prelaunch é uma oportunidade ousada que será lançada simultaneamente em cerca de 100 países, que promete revolucionar o mercado de MMN.

    A rede do World Prelaunch está sendo montada ANTES da oportunidade definitiva ser ativada, por ordem de chegada!! Isso significa que, após se cadastrar, sua rede vai se formar abaixo de você independente de seu trabalho!

    O que você precisa fazer para ativar o potencial de ganho de toda a rede abaixo de você? Convidar duas pessoas. É que o World Prelaunch usa o sistema binário, ou seja, você cadastra duas pessoas diretamente, e todas as outras que cadastrar serão lançadas mais abaixo na sua rede, fazendo parte de sua equipe, lucrando e te ajudando a lucrar.

    O que já sabemos é que a estimativa de ganhos do World Prelaunch é de 16 dólares por pessoa inscrita abaixo de você indiretamente, e 50 dólares por pessoa cadastrada diretamente por você.

    Considere que por minuto milhares de pessoas se cadastram e caem abaixo de você na sua rede. Imaginou o ganho potencial? O que você ainda está esperando? Falta menos de um mês!!!
    1) Acesse meu site pessoal para fazer parte da minha equipe: www.worldprelaunch.com/valdo109
    2) Registre-se gratuitamente clicando no botão Join.
    3) Vá em seu e-mail e clique no link para ativar o seu site pessoal World Prelaunch.
    4) Compartilhe o seu site pessoal com a família, amigos, colegas de trabalho, internautas, líderes, formadores de equipes, comerciantes online. Lembre-se que com quanto mais pessoas você compartilha o seu site, maior será sua equipe.
    LINK PARA CADASTRO: copie e cole no seu navegadorwww.worldprelaunch.com/valdo109

    ReplyDelete