A collection of libraries and scripts to enhance and ease PHP web development.Project includes:
Image Create for PHPlibHtmlForm for PHPVariables from URI for PHPOptimize Database for
MYSQLChopspaces for PHPHTML special chars encode for PHP
/** Prototypes: html_textarea($name, $value='', $cols=40, $rows=5) html_input_hidden($name, $value) html_input_radio($name, $value, $checked=FALSE) html_input_checkbox($name, $value, $checked=FALSE) html_input_text($name, $value='', $size=20, $maxlength=100) html_input_password($name, $value='', $size=20, $maxlength=100) html_input_submit($name='button', $value=' GO ') html_input_reset($value=' CANCEL ') html_select($name, $value_description_array, $value_selected='', $size=1, $multiple=FALSE) See each individual function for full usage!!! **/ function html_textarea($name, $value='', $cols=40, $rows=5) { /** wrap="virtual" is not part of any W3C HTML standard; at least ** up to 4.01, but nearly any decent browser knows it, and if ** it doesn't oh well. It is too nice to not include here. **/ $buf = '<textarea wrap="virtual" name="' .htmlspecialchars($name). '" rows="' .$rows. '" cols="' .$cols. '">' . htmlspecialchars($value) . '</textarea>'; return $buf; } function html_input_hidden($name, $value) { $buf = '<input type="hidden" name="' .htmlspecialchars($name). '" value="' .htmlspecialchars($value). '">'; return $buf; } function html_input_radio($name, $value, $checked=FALSE) { /** The following allows for making sure that no two radio buttons ** of the same name can ever be checked. Once one is checked, no ** subsequent ones will be allowed to be checked. I used md5 just because it ** produces a unique hash where all characters are valid for a variable ** name in PHP and which is then made into the static variable ** which is where the state is saved. ** ChangeLog. ** Had to use 'global' instead of static. Static was erroring out ** for some reason. **/ $namesum = md5($name); $state = 'radio_' . $namesum; global $$state; $tmp = ''; if ($checked && !$$state) { $$state = TRUE; $tmp = ' checked'; } $buf = '<input type="radio" name="' .htmlspecialchars($name). '" value="' .htmlspecialchars($value). '"' .$tmp. '>'; unset($tmp); unset($state); return $buf; } function html_input_checkbox($name, $value, $checked=FALSE) { $tmp = ''; if ($checked) $tmp = ' checked'; $buf = '<input type="checkbox" name="' .htmlspecialchars($name). '" value="' .htmlspecialchars($value). '"' .$tmp. '>'; return $buf; } function html_input_text($name, $value='', $size=20, $maxlength=100) { if ($size > $maxlength) ($maxlength <=0) ? $maxlength = $size : $size = $maxlength; if (strlen($value) > $maxlength) $value = substr($value, 0, $maxlength); $buf = '<input type="text" name="' .htmlspecialchars($name). '" value="' .htmlspecialchars($value). '" size="' .$size. '" maxlength="' .$maxlength. '">'; return $buf; } function html_input_password($name, $value='', $size=20, $maxlength=100) { if ($size > $maxlength) $size = $maxlength; if (strlen($value) > $maxlength) $value = substr($value, 0, $maxlength); $buf = '<input type="password" name="' .htmlspecialchars($name). '" value="' .htmlspecialchars($value). '" size="' .$size. '" maxlength="' .$maxlength. '">'; return $buf; } function html_input_submit($name='button', $value=' GO ') { $buf = '<input type="submit" name="' .htmlspecialchars($name). '" value="' .htmlspecialchars($value). '">'; return $buf; } function html_input_reset($value=' CANCEL ') { $buf = '<input type="reset" value="' .htmlspecialchars($value). '">'; return $buf; } function html_select($name, $value_description_array, $value_selected='', $size=1, $multiple=FALSE) { $num_elements = count($value_description_array); if ($size > $num_elements) $size = $num_elements; $mul = ''; if ($multiple) $mul = ' multiple'; $buf = '<select name="' .htmlspecialchars($name). '" size="' .$size. '"' .$mul. '>' . "\n"; /** make sure tmp[0] exists and is NULL, ** needed for this to work corectly **/ $tmp[''] = ''; if(is_array($value_selected) && count($value_selected)) while(list($key_tmp, $v) = each($value_selected)) $tmp[$v] = ' selected'; else $tmp[$value_selected] = ' selected'; /** Using error_reporting() here is a ** hack to make sure printing out $tmp[unset] doesn't bitch. ** Doing it this way is much quicker than doing a compare each ** time through the loop **/ $orig_error = error_reporting(0); while(list($key, $val) = each($value_description_array)) $buf .= ' <option value="' .htmlspecialchars($key). '"' .$tmp[$key]. '>' .$val. "\n"; error_reporting($orig_error); unset($tmp); unset($orig_error); unset($mul); $buf .= '</select>'; return $buf; }

No Responses to “PHP Development tools”