Sven Generator - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Sven Generator.php
- <?php
- class Sven {
- public function isTrue() {
- return false;
- }
- public function genereteAnswer() {
- $phrases = array(
- 'I am',
- 'bitch',
- 'do',
- 'you',
- 'have',
- 'any',
- 'news',
- 'for',
- 'me'
- );
- $answer = '';
- $count = rand(1, 8);
- for($i = 1; $i < $count; $i++) {
- $answer .= $phrases[array_rand($phrases)];
- if($i + 1 != $count)
- $answer .= ' ';
- }
- $answer .= rand(0,1) %2 == 0 ? '?' : '!';
- return ucfirst($answer);
- }
- }
- $superman = new Sven();
- echo '<strong>Q:</strong> Hi Sven, do you have a minute?' . "\n";
- echo '<strong>A:</strong> ' . ($superman->isTrue() ? 'How can I help you' : $superman->genereteAnswer());
File Description
- Sven Generator
- PHP Code
- 20 Jun-2018
- 852 Bytes
You can Share it:
Latest PHP Pastes