| Home  | Casa  | Hardware  | Networking  | Programmazione  | Software  | Domanda  | Sistemi  |   
Programmazione  
  • C /C + + Programming

  • Computer Programming Languages

  • Delphi Programming

  • Java Programming

  • Programmazione Javascript

  • PHP /MySQL Programmazione

  • Perl Programming

  • Python Programming

  • rubino Programmazione

  • Nozioni di base di Visual Programming
  •  
    Conoscenza Informatica >> Programmazione >> PHP /MySQL Programmazione >> Content
    Come creare RSS con PHP
    Really Simple Syndication , o RSS , è un formato standard per la distribuzione di informazioni su Internet . Molti siti web forniscono notizie RSS mangimi contenenti o il contenuto che viene aggiornato in tandem con il sito e agli utenti di iscriversi ad un feed per ricevere gli aggiornamenti. A differenza di e-mail , RSS consente agli utenti di decidere quali informazioni desiderano ricevere e un utente può annullare l'iscrizione a un feed in qualsiasi momento . È possibile creare un feed RSS utilizzando il linguaggio di scripting PHP , attraverso la comprensione del formato RSS e la scrittura di output XML che segue il formato . Istruzioni
    1

    Commenta il formato RSS 2.0 per capire come le informazioni devono essere strutturati in un feed RSS . Creare un nuovo file PHP in un editor o utilizzando il Blocco note.
    2

    Creare una classe per il canale RSS . Includi titolo, link e descrizione , che sono i campi richiesti RSS . Aggiungi un array per memorizzare gli elementi RSS . Creare la funzione di costruzione per creare una nuova istanza del canale . Ad esempio, digitare : ?

    < Php
    class

    RSS_channel {

    pubblica $ titolo , $ connessione , $ descrizione ;

    public function __ construct ( $ titolo , $ connessione , $ descrizione) {

    $ this - > title = $ title ;

    $ this-> link = $ link ;

    $ questo - > descrizione = $ descrizione ;

    $ this-> items = array () ; }


    3

    Creare un metodo per aggiungere un nuovo elemento alla matrice . Chiamare una classe elemento RSS che si creerà dopo. Ad esempio, digitare :

    new_item funzione pubblica ( $ titolo , $ connessione , $ descrizione) {

    array_push ( $ this - > oggetti , nuovo ( $ titolo , $ link RSS_item , $ descrizione) ) ; }


    4

    creare una funzione per emettere il codice XML e RSS informazioni di intestazione per il file RSS . Ad esempio, digitare :

    RSS_header funzione pubblica ( ) {

    $ r = ' < xml version = "1.0" ? ? > ';

    $ R . = ' versione ';
    ritorno

    $ r ;

    }
    5

    Creare un metodo per l'uscita del canale RSS . Uscita i tag XML e gli elementi di dati per il canale. Chiamare la classe elemento RSS per emettere i tag XML e gli elementi dati di ciascun elemento nel canale. Ad esempio, digitare : .

    Uscita funzione pubblica ( ) {

    $ r = RSS_header ();

    $ r = " " ;

    $ r . = " " . $ this-> titolo. " < /title >" . <br> <p> $ r = " <link> " . $ this-> collegamento . " < /link > " ; <br> <p> $ r = " <description> " . . $ this-> descrizione . " < /description >" . <br> <p> foreach ( $ this-> oggetti da $ item) { <br> <p> $ r = $ item- > Output ( ) ; <br> < p > } <br> <p> $ r = " < /channel >" . <br> <p> $ r = " < /rss >" . <br> <p> } <br> < p > } <br> 6 <p> creare la classe elemento RSS con un titolo, link e la descrizione . Creare una funzione di costruzione per creare una nuova istanza della classe . Ad esempio, digitare : <br> classe <p> RSS_item { <br> <p> pubblica $ titolo , $ connessione , $ descrizione ; <br> <p> public function __ construct ( $ titolo , $ connessione , $ descrizione) { <br> <p> $ this-> title = $ title ; <br> <p> $ this-> link = $ link ; <br> <p> $ this-> descrizione = $ descrizione ; < br > <p> } <br> 7 <p> Creare un metodo per produrre i contenuti della voce RSS . Ad esempio, digitare : <br> <p> uscita funzione pubblica ( ) { <br> <p> $ r = " <item> " ; <br> <p> $ r = " <title> " . . $ this-> titolo. " < /title >" . <br> <p> $ r = " <link> " . $ this-> collegamento . " < /link > " ; <br> <p> $ r = " <description> " . . $ this-> descrizione . " < /description > " ; <br> <p> $ r = " </item >" . <br> ritorno <p> $ r ; <br> <p> } <br> <p> } <br> 8 <p> Crea un nuovo canale RSS e aggiungere elementi RSS . Emettere il feed RSS per lo schermo. Ad esempio, digitare : <br> <p> $ rss = new RSS_channel ( "News " , " http://example.com/news " , "Esempio News" , " mer 1 giu 2011 13:02:01 +0000 " , " http://example.com "); <br> <p> $ rss - > new_item ( " rapporto di guadagni " , " http://example.com/earnings " , " guadagni rapporto per Example.com " ) ; <br> <p> $ rss - > new_item ( " Meeting del Capitale " , " http://example.com/shmeeting "," Meeting Announcement della Capitale "); <br> <p> $ rss - > , new_item ( " CEO Speech " , " http://example.com/ceospeech " , "Esempio CEO tiene un discorso " ) ; <br> <p> echo $ rss - > Output ( ) ; <br> <p> ? > <br> <br> <div class=ad2><script language='javascript' src='/ad/201310/4.js'></script></div> </div> </td> </tr> </table> <table width="95%" height="1" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#DEE7EE"> <tr> <td></td> </tr> </table> <table width="100%" height="7" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table width="91%" height="52" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="51%"><p>Previous : <a class='LinkPrevArticle' href='/Programmazione/php-mysql-programming/92217.html' >Come installare un Sistema di Spedizione UPS VirtueMart </a></li></p></td> </tr> <tr> <td width="49%"> next : <a class='LinkNextArticle' href='/Programmazione/php-mysql-programming/92219.html' >Come Flush Output durante l'elaborazione in PHP </a></li></td> </tr> </table></td> </tr> </table> <table width="100%" height="7" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table width="770" height="246" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="375" height="246" valign="top"><table width="380" border="0" cellpadding="0" cellspacing="0" class="bian"> <tr> <td height="244" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="img_dm/danmai_r4_c04 -.jpg" bgcolor="#DBE3EE"> <tr> <td width="4%" height="29"> </td> <td width="96%" class="lan_lm"> Articoli Correlati </td> </tr> </table> <table width="95%" height="209" border="0" align="center" cellpadding="0" cellspacing="4"> <tr> <td height="201"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91315.html" title="MySQL Error 1030 " target="_self">MySQL Error 1030 </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92326.html" title="Come scrivere ottali di numeri in PHP " target="_self">Come scrivere ottali di numeri in PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91658.html" title="Fasi della programmazione PHP " target="_self">Fasi della programmazione PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/93106.html" title="Come costruire un sito Web PHP " target="_self">Come costruire un sito Web PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91382.html" title="MySQL Vs testo . Varchar " target="_self">MySQL Vs testo . Varchar </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92502.html" title="Come trovare le parole in un file con PHP " target="_self">Come trovare le parole in un file con PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91603.html" title="Come personaggi di uscita con una query MySQL " target="_self">Come personaggi di uscita con una query MySQL </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91582.html" title="PHP connessioni persistenti causano MySQL carico " target="_self">PHP connessioni persistenti causano MySQL carico </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91575.html" title="Come convertire Excel in formato CSV in PHP " target="_self">Come convertire Excel in formato CSV in PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91842.html" title="Come utilizzare Casella di controllo in PHP " target="_self">Come utilizzare Casella di controllo in PHP </a></td></tr><tr></tr></table></td> </tr> </table></td> </tr> </table></td> <td width="20" valign="top"></td> <td width="375" valign="top"><table width="380" border="0" cellpadding="0" cellspacing="0" class="bian"> <tr> <td height="244" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="img_dm/danmai_r4_c04 -.jpg" bgcolor="#DBE3EE"> <tr> <td width="4%" height="29"> </td> <td width="96%" class="lan_lm">Articoli in evidenza </td> </tr> </table> <table width="95%" height="207" border="0" align="center" cellpadding="0" cellspacing="4"> <tr> <td height="199"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92344.html" title="Come impostare il valore da una query MySQL come una variabile in PHP " target="_self">Come impostare il valore da una query MySQL come una va…</a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/95341.html" title="Come creare VBS script di login " target="_self">Come creare VBS script di login </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/python-programming/93727.html" title="Come sincronizzare code via XML-RPC in Python " target="_self">Come sincronizzare code via XML-RPC in Python </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/94473.html" title="Come faccio a scrivere Updategrams XML Script in VB6 ? " target="_self">Come faccio a scrivere Updategrams XML Script in VB6 ? </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/96129.html" title="Come rimuovere i duplicati da un ArrayList " target="_self">Come rimuovere i duplicati da un ArrayList </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/python-programming/93569.html" title="Come leggere i file txt in Tuple in Python " target="_self">Come leggere i file txt in Tuple in Python </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/87354.html" title="Come sostituire Point Rettangoli Pareggio in WPF " target="_self">Come sostituire Point Rettangoli Pareggio in WPF </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/87955.html" title="Come controllare per Attributi Visibilità primari " target="_self">Come controllare per Attributi Visibilità primari </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/86723.html" title="Come calcolare offset Assembly Language " target="_self">Come calcolare offset Assembly Language </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/86588.html" title="Come conservare gestire MATLAB " target="_self">Come conservare gestire MATLAB </a></td></tr><tr></tr></table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table> <table width="980" height="8" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table border=0 cellSpacing=0 cellPadding=0 width=980 bgColor=#36506e height=90> <tr> <td class=bs height=90 align=middle>Copyright © Conoscenza Informatica http://it.wingwit.com <script language='javascript' src='/ad/201310/1.js'></script></td> </tr> </table> </div> </body> </html>