PageRenderTime 48ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext/std/ext_std_output.php

http://github.com/facebook/hiphop-php
PHP | 267 lines | 59 code | 28 blank | 180 comment | 0 complexity | 0bfa794cd79038048374ab4d6b44d3f6 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh // partial
  2. // generated by idl-to-hni.php
  3. namespace {
  4. /** This function will turn output buffering on. While output buffering is
  5. * active no output is sent from the script (other than headers), instead the
  6. * output is stored in an internal buffer. The contents of this internal
  7. * buffer may be copied into a string variable using ob_get_contents(). To
  8. * output what is stored in the internal buffer, use ob_end_flush().
  9. * Alternatively, ob_end_clean() will silently discard the buffer contents.
  10. * Warning Some web servers (e.g. Apache) change the working directory of a
  11. * script when calling the callback function. You can change it back by e.g.
  12. * chdir(dirname($_SERVER['SCRIPT_FILENAME'])) in the callback function.
  13. * Output buffers are stackable, that is, you may call ob_start() while
  14. * another ob_start() is active. Just make sure that you call ob_end_flush()
  15. * the appropriate number of times. If multiple output callback functions are
  16. * active, output is being filtered sequentially through each of them in
  17. * nesting order.
  18. * @param mixed $output_callback - An optional output_callback function may be
  19. * specified. This function takes a string as a parameter and should return a
  20. * string. The function will be called when the output buffer is flushed
  21. * (sent) or cleaned (with ob_flush(), ob_clean() or similar function) or when
  22. * the output buffer is flushed to the browser at the end of the request. When
  23. * output_callback is called, it will receive the contents of the output
  24. * buffer as its parameter and is expected to return a new output buffer as a
  25. * result, which will be sent to the browser. If the output_callback is not a
  26. * callable function, this function will return FALSE. If the callback
  27. * function has two parameters, the second parameter is filled with a
  28. * bit-field consisting of PHP_OUTPUT_HANDLER_START, PHP_OUTPUT_HANDLER_CONT
  29. * and PHP_OUTPUT_HANDLER_END. If output_callback returns FALSE original
  30. * input is sent to the browser. The output_callback parameter may be
  31. * bypassed by passing a NULL value. ob_end_clean(), ob_end_flush(),
  32. * ob_clean(), ob_flush() and ob_start() may not be called from a callback
  33. * function. If you call them from callback function, the behavior is
  34. * undefined. If you would like to delete the contents of a buffer, return ""
  35. * (a null string) from callback function. You can't even call functions using
  36. * the output buffering functions like print_r($expression, true) or
  37. * highlight_file($filename, true) from a callback function. In PHP 4.0.4,
  38. * ob_gzhandler() was introduced to facilitate sending gz-encoded data to web
  39. * browsers that support compressed web pages. ob_gzhandler() determines what
  40. * type of content encoding the browser will accept and will return its output
  41. * accordingly.
  42. * @param int $chunk_size - If the optional parameter chunk_size is passed,
  43. * the buffer will be flushed after any output call which causes the buffer's
  44. * length to equal or exceed chunk_size. Default value 0 means that the
  45. * function is called only in the end, other special value 1 sets chunk_size
  46. * to 4096.
  47. * @param bool $erase - If the optional parameter erase is set to FALSE, the
  48. * buffer will not be deleted until the script finishes. This causes that
  49. * flushing and cleaning functions would issue a notice and return FALSE if
  50. * called.
  51. * @return bool - Returns TRUE on success or FALSE on failure.
  52. */
  53. <<__Native>>
  54. function ob_start(mixed $output_callback = null,
  55. int $chunk_size = 0,
  56. int $flags = PHP_OUTPUT_HANDLER_STDFLAGS): bool;
  57. /** This function discards the contents of the output buffer. This function
  58. * does not destroy the output buffer like ob_end_clean() does.
  59. */
  60. <<__Native>>
  61. function ob_clean(): void;
  62. /** This function will send the contents of the output buffer (if any). If you
  63. * want to further process the buffer's contents you have to call
  64. * ob_get_contents() before ob_flush() as the buffer contents are discarded
  65. * after ob_flush() is called. This function does not destroy the output
  66. * buffer like ob_end_flush() does.
  67. */
  68. <<__Native>>
  69. function ob_flush(): bool;
  70. /** This function discards the contents of the topmost output buffer and turns
  71. * off this output buffering. If you want to further process the buffer's
  72. * contents you have to call ob_get_contents() before ob_end_clean() as the
  73. * buffer contents are discarded when ob_end_clean() is called.
  74. * @return bool - Returns TRUE on success or FALSE on failure. Reasons for
  75. * failure are first that you called the function without an active buffer or
  76. * that for some reason a buffer could not be deleted (possible for special
  77. * buffer).
  78. */
  79. <<__Native>>
  80. function ob_end_clean(): bool;
  81. /** This function will send the contents of the topmost output buffer (if any)
  82. * and turn this output buffer off. If you want to further process the
  83. * buffer's contents you have to call ob_get_contents() before ob_end_flush()
  84. * as the buffer contents are discarded after ob_end_flush() is called. This
  85. * function is similar to ob_get_flush(), except that ob_get_flush() returns
  86. * the buffer as a string.
  87. * @return bool - Returns TRUE on success or FALSE on failure. Reasons for
  88. * failure are first that you called the function without an active buffer or
  89. * that for some reason a buffer could not be deleted (possible for special
  90. * buffer).
  91. */
  92. <<__Native>>
  93. function ob_end_flush(): bool;
  94. /** Flushes the write buffers of PHP and whatever backend PHP is using (CGI, a
  95. * web server, etc). This attempts to push current output all the way to the
  96. * browser with a few caveats. flush() may not be able to override the
  97. * buffering scheme of your web server and it has no effect on any client-side
  98. * buffering in the browser. It also doesn't affect PHP's userspace output
  99. * buffering mechanism. This means you will have to call both ob_flush() and
  100. * flush() to flush the ob output buffers if you are using those. Several
  101. * servers, especially on Win32, will still buffer the output from your script
  102. * until it terminates before transmitting the results to the browser. Server
  103. * modules for Apache like mod_gzip may do buffering of their own that will
  104. * cause flush() to not result in data being sent immediately to the client.
  105. * Even the browser may buffer its input before displaying it. Netscape, for
  106. * example, buffers text until it receives an end-of-line or the beginning of
  107. * a tag, and it won't render tables until the </table> tag of the outermost
  108. * table is seen. Some versions of Microsoft Internet Explorer will only
  109. * start to display the page after they have received 256 bytes of output, so
  110. * you may need to send extra whitespace before flushing to get those browsers
  111. * to display the page.
  112. */
  113. <<__Native>>
  114. function flush(): void;
  115. /** Gets the current buffer contents and delete current output buffer.
  116. * ob_get_clean() essentially executes both ob_get_contents() and
  117. * ob_end_clean().
  118. * @return mixed - Returns the contents of the output buffer and end output
  119. * buffering. If output buffering isn't active then FALSE is returned.
  120. */
  121. <<__Native>>
  122. function ob_get_clean(): mixed;
  123. /** Gets the contents of the output buffer without clearing it.
  124. * @return mixed - This will return the contents of the output buffer or
  125. * FALSE, if output buffering isn't active.
  126. */
  127. <<__Native>>
  128. function ob_get_contents(): mixed;
  129. /** ob_get_flush() flushes the output buffer, return it as a string and turns
  130. * off output buffering. This function is similar to ob_end_flush(), except
  131. * that this function returns the buffer as a string.
  132. * @return mixed - Returns the output buffer or FALSE if no buffering is
  133. * active.
  134. */
  135. <<__Native>>
  136. function ob_get_flush(): mixed;
  137. /** This will return the length of the contents in the output buffer.
  138. * @return int - Returns the length of the output buffer contents or FALSE if
  139. * no buffering is active.
  140. */
  141. <<__Native>>
  142. function ob_get_length(): int;
  143. /** Returns the nesting level of the output buffering mechanism.
  144. * @return int - Returns the level of nested output buffering handlers or zero
  145. * if output buffering is not active.
  146. */
  147. <<__Native>>
  148. function ob_get_level(): int;
  149. /** ob_get_status() returns status information on either the top level output
  150. * buffer or all active output buffer levels if full_status is set to TRUE.
  151. * @param bool $full_status - TRUE to return all active output buffer levels.
  152. * If FALSE or not set, only the top level output buffer is returned.
  153. * @return array
  154. */
  155. <<__Native>>
  156. function ob_get_status(bool $full_status = false): varray_or_darray;
  157. /** ob_implicit_flush() will turn implicit flushing on or off. Implicit
  158. * flushing will result in a flush operation after every output call, so that
  159. * explicit calls to flush() will no longer be needed.
  160. * @param bool $flag - TRUE to turn implicit flushing on, FALSE otherwise.
  161. */
  162. <<__Native>>
  163. function ob_implicit_flush(bool $flag = true): void;
  164. /** Lists all output handlers in use.
  165. * @return array - This will return an array with the output handlers in use
  166. * (if any). If output_buffering is enabled or an anonymous function was used
  167. * with ob_start(), ob_list_handlers() will return "default output handler".
  168. */
  169. <<__Native>>
  170. function ob_list_handlers(): varray;
  171. /** Adds an entry to a log file that's written when server crashes. This is
  172. * useful for diagnose why server crashed. For example, logged-on user's ID.
  173. * @param string $name - Name of the value.
  174. * @param string $value - Value to write to log.
  175. */
  176. <<__HipHopSpecific, __Native>>
  177. function hphp_crash_log(string $name,
  178. string $value): void;
  179. /** Tallies a number for server stats.
  180. * @param string $name - Name of the entry. This name can then be used with
  181. * admin commands to retrieve stats while server is running.
  182. * @param int $value - An integer to add up.
  183. */
  184. <<__HipHopSpecific, __Native>>
  185. function hphp_stats(string $name,
  186. int $value): void;
  187. /** Checks current value of a server stats.
  188. * @param string $name - Name of the entry.
  189. * @return int - Currently accumulated count.
  190. */
  191. <<__HipHopSpecific, __Native>>
  192. function hphp_get_stats(string $name): int;
  193. /** Returns status of different server threads.
  194. * @return array - Array of thread statuses.
  195. */
  196. <<__HipHopSpecific, __Native>>
  197. function hphp_get_status(): darray;
  198. /** Returns I/O status of current thread. EnableNetworkIOStatus has to be
  199. * turned on.
  200. * @return array - Array of all I/O so far for current thread.
  201. */
  202. <<__HipHopSpecific, __Native>>
  203. function hphp_get_iostatus(): darray;
  204. <<__HipHopSpecific, __Native, __Deprecated("this will be removed")>>
  205. function hphp_set_iostatus_address(string $name): void;
  206. /** Returns timestamps of different request events.
  207. * @param bool $get_as_float - same as in microtime() to specify output
  208. * format, except it defaults to true for float format.
  209. * @return mixed - An array of three timestamps: 'queue', the time a request
  210. * is received and queued up; 'process-wall', the wall clock time a request
  211. * starts to get processed; and 'process-cpu', the CPU clock time a request
  212. * starts to get processed.
  213. */
  214. <<__HipHopSpecific, __Native>>
  215. function hphp_get_timers(bool $get_as_float = true): mixed;
  216. /** Dumps all variables in global state, including global variables, static
  217. * variables, class statics and others.
  218. * @param bool $serialize - Specifies what format to use, whether to serialize
  219. * into a string.
  220. * @return mixed - An array of global state.
  221. */
  222. <<__HipHopSpecific, __Native>>
  223. function hphp_output_global_state(bool $serialize = true): mixed;
  224. /** @return int - Returns the current instruction counter value.
  225. */
  226. <<__HipHopSpecific, __Native("NoInjection")>>
  227. function hphp_instruction_counter(): int;
  228. /** @return mixed - An array of hardware counters
  229. */
  230. <<__HipHopSpecific, __Native("NoInjection")>>
  231. function hphp_get_hardware_counters(): mixed;
  232. /** @param string $events - comma separated list of hardware events
  233. * @return bool - returns TRUE on success and FALSE on failure
  234. */
  235. <<__HipHopSpecific, __Native("NoInjection")>>
  236. function hphp_set_hardware_events(?string $events = null): bool;
  237. <<__HipHopSpecific, __Native("NoInjection")>>
  238. function hphp_clear_hardware_events(): void;
  239. } // root namespace