This is very simple PHP Random Script to get Text from txt file and show it where you want to show. You can easy include it by PHP code or using java script to include it. With java script, you can easy share your random quote, just give theme a code, that’s all. PHP Random Quote run with 4 files inside. Here is how you install it:
Upload all file inside folder: php-random-quote to your web host. Edit file bienthuy.txt to your need.
One quote per line. You can enter quote as much as you want, just remember ONE PER LINE
Then run it in your browser: domain.com/php-random-quote/index.php

Demo PHP Random Quotes: https://demo.bienthuy.com/php/random-text/

If you want to share it, just give your friend Java Script like this:

<script type="text/javascript" src="https://demo.bienthuy.com/php/random-text/btrand.php?type=1"></script>

Files Content: ONE PER LINE, you can use html code in this txt file.
bienthuy.txt

Không có gì quý hơn độc lập tự do
Vietnam Today Travel - <a href="https://www.vietnamtodaytravel.com">Vietnam Tours</a>
UTF-8 Supported - <a href="https://www.bienthuy.com">Biên Thùy</a>
UTF-8 with <i><b>HTML code</b></i> Supported <b>Bold</b> and <i>Italic</i> <font color="#0066cc">Event color </font>- <a href="https://www.bienthuy.com">Biên Thùy</a>
Huy Hoa - <a href="https://www.huyhoa.com">Huy Hòa</a>!
Nothing gonna change my love for you
Go to - <a href="https://www.bienthuy.com">Biên Thùy</a> for details and download link

btrand.php

<?php
/*
* Shared by BienThuy.Com
* www.BienThuy.Com
* wWw.HuyHoa.Com
* [email protected]
* Yahoo: huyhoa
* Skype: admin.vtt
* Facebook: https://www.facebook.com/tinhcaviet
* Twitter: https://www.twitter.com/tinhcaviet
* @ 2013. All Rights Reserved.
*/
/* File, where the random text/quotes are stored one per line */
$settings['text_from_file'] = 'bienthuy.txt';
$settings['quotes'] = array(
'1',
'2
3
4',
'5',
'6',
'7!',
'8',
'9!',
);
/*
   How to display the text?
   0 = raw mode: print the text as it is, when using RanTex as an include
   1 = Javascript mode: when using Javascript to display the quote
*/
$settings['display_type'] = 1;
/* Allow on-the-fly settings override? 0 = NO, 1 = YES */
$settings['allow_otf'] = 1;
/*******************************************************************************
*  DO NOT EDIT BELOW...
*
*  ...or at least make a backup before you do!
*******************************************************************************/
/* Override type? */
if ($settings['allow_otf'] && isset($_GET['type']))
{
    $type = intval($_GET['type']);
}
else
{
    $type = $settings['display_type'];
}
/* Get a list of all text options */
if ($settings['text_from_file'])
{
    $settings['quotes'] = file($settings['text_from_file']);
}
/* If we have any text choose a random one, otherwise show 'No text to choose from' */
if (count($settings['quotes']))
{
    $txt = $settings['quotes'][array_rand($settings['quotes'])];
}
else
{
    $txr = 'No text to choose from';
}
/* Output the image according to the selected type */
if ($type)
{
    /* New lines will break Javascript, remove any and replace them with <br /> */
    $txt = nl2br(trim($txt));
    $txt = str_replace(array("\n","\r"),'',$txt);
    echo 'document.write(\''.addslashes($txt).'\')';
}
else
{
    echo $txt;
}
?>

Using:  If you use PHP, then include it where you want to show

<?php $_GET['type'] = 0; include 'btrand.php'; ?>

If you want to use Java Script or want to share, use this code:

<script type="text/javascript" src="/ht/btrand.php?type=1"></script>

If share, just edit the link:

<script type="text/javascript" src="https://demo.bienthuy.com/php/random-text/btrand.php?type=1"></script>

Download PHP Random Quote: https://yyen.info/A3IWdo2YXD

4.6/5 - (6935 bình chọn)

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *