Reputation: 19587
In several online resources I've seen the examples like in the picture below. So, How can I run it? Is it possible?
I know about interactive mode (php -a) or run code without using script tags (php -r), but all of them differ from example below..
Upvotes: 0
Views: 119
Reputation: 4267
ctrl + D is something new to me
To run simple code in php, I used to use php -r
php -r 'for ($i=0; $i<3; $i++) { echo $i . "\n"; }'
Upvotes: 0
Reputation: 63442
One way would be from stdin:
echo '<?php echo "hello world!"; ?>' | php
Another way would be to use Ctrl + D:
$ php
<?php
echo "hello world!\n";
?>
^D
hello world
$
Upvotes: 1
Reputation: 146450
Ctrl+D if I recall correctly. That's the Unix shortcut for EOF (end of file).
It's normally easier to just use files.
Upvotes: 3