summaryrefslogtreecommitdiffstats
path: root/public/settergetter.php
diff options
context:
space:
mode:
authorSimon2011-01-28 09:20:41 +0100
committerSimon2011-01-28 09:20:41 +0100
commit8f99fc035bcc8db59844118760a2f95c97a6f5f1 (patch)
tree8c25e7d56fc85219647cf6a3a0ec61554e6337d4 /public/settergetter.php
parentGetter und Setter für Models gesetzt (diff)
downloadpbs2-8f99fc035bcc8db59844118760a2f95c97a6f5f1.tar.gz
pbs2-8f99fc035bcc8db59844118760a2f95c97a6f5f1.tar.xz
pbs2-8f99fc035bcc8db59844118760a2f95c97a6f5f1.zip
settergetter für variablen - um nicht tausend sachen ändern zu müssen
Diffstat (limited to 'public/settergetter.php')
-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
+}
+