|
home—lects—exams—hws
D2L—breeze (snow day)
N.B. doc-strings (or "here-strings"): Just like double-quoted strings, except that instead of double-quote you name the delimiter.
$foo = 17; $body= <<<END_THE_MSG_BOD Hello from computer #$foo. This is a long email. It even has a second paragraph, whoah! We're using "heredoc" strings to to do that, which quotes <?phpEverything <!-- /* haha // ha. <b> --> // */ and END_THE_MSG_BOD ! (Well everything but the id provided at the start of the heredoc, starting a line.) Bye, END_THE_MSG_BOD; |
A common misunderstanding: “if I callsomeForm.submit() myself, then the browser will first look at the form's onSubmit attribute and run that”. This is false! These two are layered the other way around: the onsubmit event causes the underlying submit method to be called, not vice-versa.
- sticky form: (a) When you make the form, include 'value=...' in the tags appropriately. (b) But to do this, the page that *makes* the form has to be the same as the page that *recives* the form! (c) Imagine a big if-statement: if (this-form-was-submitted) { ...validate and print server-side error message... } if (form-was-submitted && data-is-valid) { ...handle the accepted form stuff... } else { ...print the form... echo "<input type='text' name="lastName" value=??? maxlength=??? /> } (c2) example: lect07b-sticky-form.php (d) <input type="hidden" name="i-came-from-the-form" value="true" /> (e) You can include files: require include require_once include_once
1 Post-php5.3.0, you can enclose the end-of-string delimiter itself in double-quotes. And if you use single-quotes, you get “now-docs”, which are just like single-quoted strings except that you don't need to escape any single-quotes inside of it. php docs: strings Both versions are helpful for test-cases with large outputs. ↩
home—lects—exams—hws
D2L—breeze (snow day)
©2012, Ian Barland, Radford University Last modified 2012.Oct.12 (Fri) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |