PHP not displaying correctly in HTML -
PHP not displaying correctly in HTML -
i'm trying create drop downwards box populated array. when view code browser displays pieces of php code.
here browser displays:
'; foreach ($array $value) { $html .= ' $value '; } $html .= ''; homecoming $html; } ?>
here code:
<html> <head> <title>test</title> <?php $cities = array( 'san francisco', 'san diego', 'los angeles'); function createdropdown($name, $array) { $html = '<select name=$name>'; foreach ($array $value) { $html .= '<option value="$value">$value</option>'; } $html .= '</select>'; homecoming $html; } ?> </head> <body> <form> <?php createdropdown("cities", $cities); ?> </form> </body> </html>
most server isn't configured treat .php files php scripts, , serving them html/plaintext. if view-source page happening on, you'll total php source code. <?php
seen opening html tag, isn't closed until before foreach loop, intermediate text/code "hidden" in html view.
php html arrays drop-down-menu
Comments
Post a Comment