Skip to content

Commit

Permalink
Support for PHP (with solutions)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezp committed Nov 1, 2013
1 parent 6912434 commit e6dbd04
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 1 deletion.
7 changes: 7 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ configuration:
@cat test/messages/welcome
@false

run/%: %.php configuration
@echo === $*: preparing...
@$(MAKE) -s check-hashbang/$*.php
@mkdir -p run
@cp $< $@
@chmod +x $@

run/%: %.py configuration
@echo === $*: preparing...
@$(MAKE) -s check-hashbang/$*.py
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You might need to run `gmake` on non-GNU or non-Linux systems.
Current state
=============

TDLPL currently recognizes two programming languages: Python and Ruby.
TDLPL currently recognizes two programming languages: Python, Ruby and PHP.
Adding new languages is really easy: edit the GNUmakefile to add the
corresponding rule that prepares the runnable file. The runnable file goes
into the run/ directory. Announce the new supported language in
Expand Down
6 changes: 6 additions & 0 deletions config-samples/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This is a sample configuration that indicates TDLPL the user is
# trying to learn PHP.

language PHP
mimetype text/x-php
extension php
2 changes: 2 additions & 0 deletions solutions-php/execute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/php

4 changes: 4 additions & 0 deletions solutions-php/firstarg-int.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/php
<?php
print $argv[1];
?>
4 changes: 4 additions & 0 deletions solutions-php/firstarg.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/php
<?php
print $argv[1];
?>
4 changes: 4 additions & 0 deletions solutions-php/hello.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/php
<?php
print "hello\n";
?>
4 changes: 4 additions & 0 deletions solutions-php/remainder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/php
<?php
print $argv[1] % 10;
?>
4 changes: 4 additions & 0 deletions solutions-php/square.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/php
<?php
print $argv[1]*$argv[1];
?>
4 changes: 4 additions & 0 deletions solutions-php/twoplustwo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/php
<?php
print 2+2;
?>

0 comments on commit e6dbd04

Please sign in to comment.