File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,21 @@ public function httpVersion(?string $version = null)
5454 return $ this ;
5555 }
5656
57+ /**
58+ * Output any text
59+ *
60+ * @param string $data The data to output
61+ * @param int $code The response status code
62+ */
63+ public function echo (string $ data , int $ code = 200 )
64+ {
65+ $ this ->status = $ code ;
66+ $ this ->headers ['Content-Type ' ] ??= 'text/plain ' ;
67+ $ this ->content = $ data ;
68+
69+ $ this ->send ();
70+ }
71+
5772 /**
5873 * Output plain text
5974 *
@@ -83,6 +98,21 @@ public function xml(string $data, int $code = 200)
8398
8499 $ this ->send ();
85100 }
101+
102+ /**
103+ * Output js script
104+ *
105+ * @param string $data The data to output
106+ * @param int $code The response status code
107+ */
108+ public function js (string $ data , int $ code = 200 )
109+ {
110+ $ this ->status = $ code ;
111+ $ this ->headers ['Content-Type ' ] = 'text/javascript ' ;
112+ $ this ->content = $ data ;
113+
114+ $ this ->send ();
115+ }
86116
87117 /**
88118 * Output json encoded data with an HTTP code/message
You can’t perform that action at this time.
0 commit comments