🔥 PHP - The PHP and Short Echo Tags - For Beginners

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024
  • PHP - The PHP and Short Echo Tags - For Beginners
    • PHP commands must follow an opening PHP tag. This consists of a left-angle bracket, followed by a question mark and the letters p h p
    • There must be a space, line break, tab or similar whitespace after the final p
    • If your document only contains PHP code, you should not use a closing PHP tag, as any accidental whitespace after the closing tag will be output to the browser and may cause issues.
    • However, if you are going to mix PHP and HTML in the same document, you will need to use a closing tag to indicate that the block of PHP code has ended, and direct output to the browser has begun.
    • The closing tag consists of a question mark and a right-angle bracket.
    • Place your PHP code between the tags.
    • This print statement sends the text between the quotation marks to the browser. The semicolon at the end of the line indicates that the statement has ended. You can include any number of statements or other PHP elements between the PHP tags.
    • REFRESHING our browser, we can see the output of the print statement.
    • Anything after the PHP tags is output directly to the browser.
    • This is a simple paragraph in HTML code.
    • REFRESHING our browser, we can see the HTML output.
    • Lets create a variable called $more_text that we can use to hold additional output.
    • Variable names begin with a dollar sign. We use the equals sign to assign it a value, and if we are assigning a string we put the string in quotes. Like the print statement, this statement ends in a semicolon.
    • Now we are going to create a short echo tag, which provides a convenient shorthand to echo content to the browser.
    • The short echo tag begins with a left-angle bracket, a question mark, and an equals sign.
    • This is followed by the name of the variable containing the content which you wish to echo.
    • We must close the short echo tag with a question mark and a right-angle bracket.
    • REFRESHING our browser, we can see the short echo tag output.
    Beginners, Tutorial, Lesson, Class, How To, Instructions, Teachable, Teacher, Classroom

Комментарии • 1