summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--public/settergetter.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/public/settergetter.php b/public/settergetter.php
new file mode 100644
index 0000000..42f73ef
--- /dev/null
+++ b/public/settergetter.php
@@ -0,0 +1,37 @@
+<?php
+function print_a($v){echo"<pre style='background-color:#FFCC33'>";print_r($v);echo"</pre>";}
+function setget($name){
+ $withdash = $name;
+ $withoutdash = substr($name,1);
+ return
+' public function get'.ucfirst($withoutdash).'()
+ {
+ return $this->'.$withdash.';
+ }
+ public function set'.ucfirst($withoutdash).'($'.$withdash.')
+ {
+ $this->'.$withdash.' = $'.$withdash.';
+ }
+';
+}
+if(isset($_POST['submit'])){
+ $ar = explode("\n",trim($_POST['variables']));
+
+ $output = "";
+ foreach($ar as $item){
+ $output .= setget("_".trim($item));
+ }
+ print_a($output);
+ echo "<a href='".$_SERVER['PHP_SELF']."'>back</a>";
+}
+
+else{
+?>
+<form method='post' action='<?php $_SERVER['PHP_SELF'];?>'>
+<textarea name='variables'>
+</textarea><br>
+<input type='submit' name='submit' value='setter und getter generieren'>
+</form>
+<?php
+}
+