Tag Archives: php

List of PHP Frameworks

Here’s a list of recent and popular PHP frameworks as of 2012: Kohana: The Swift PHP Framework Laravel – A Clean & Classy PHP Framework Getting Started with the Fuel PHP Framework | Nettuts+ FUEL — A simple, flexible, community driven PHP5.3 framework. › A simple, flexible, community driven PHP5.3 framework.  Underscore.php

Posted in Linux, Web Development | Tagged , | 1 Comment

iPower: The server encountered an unexpected condition which prevented it from fulfilling the request.

iPower: The server encountered an unexpected condition which prevented it from fulfilling the request. If you’re getting this error on iPower you need to enable CGI / scripts. Sometimes your account will show you that this is enabled, even if it is not. Contact iPower support to get them to resolve it for you. Even if in your control panel homepage CGI / PHP is showing up as active, click on the server configuration tab and you probably will see that CGI is in fact inactive:

Posted in Server Admin, Server Administration, Web Development | Tagged , , , , , , | Leave a comment

Fix “Post Types Order” plugin error with HTTPS

The WordPress Plugin Post Types Order by NSP CODE is helpful in as it allows you to Order Posts and Post Types Objects using a Drag and Drop Sortable javascript capability But unfortunately the plugin does not work with wordpress HTTPS / SSL admin – or at least not without errors: But the good news is that there is an easy fix with changing just a few lines of code: At the top of the post-types-order.php page there are two constant definitions: define(‘CPTPATH’, ABSPATH.’wp-content/plugins/post-types-order’); define(‘CPTURL’, get_option(‘siteurl’).’/wp-content/plugins/post-types-order’); And the second one needs to use the plugins_url() function that WordPress recommends instead: define(‘CPTPATH’, ABSPATH.’wp-content/plugins/post-types-order’); define(‘CPTURL’, plugins_url().’/post-types-order’); After that you should stop receiving the HTTPS error for some insecure content when you are in the WP administration interface.

Posted in Tech Tips, Web Development | Tagged , , , , , | Leave a comment

PHP Auto Generate Status Header: function

PHP Function to Auto Generate Status Header This is from the CodeIgnitor Common Functions Library. It is very useful: // ———————————————————————— /** * Set HTTP Status Header * * @access public * @param int the status code * @param string * @return void */ if ( ! function_exists(‘set_status_header’)) { function set_status_header($code = 200, $text = ”) { $stati = array( 200 => ‘OK’, 201 => ‘Created’, 202 => ‘Accepted’, 203 => ‘Non-Authoritative Information’, 204 => ‘No Content’, 205 => ‘Reset Content’, 206 => ‘Partial Content’, 300 => ‘Multiple Choices’, 301 => ‘Moved Permanently’, 302 => ‘Found’, 304 => ‘Not Modified’, 305 => ‘Use Proxy’, 307 => ‘Temporary Redirect’, 400 => ‘Bad Request’, 401 => ‘Unauthorized’, 403 => ‘Forbidden’, 404 => ‘Not Found’, 405 => ‘Method Not Allowed’, 406 => ‘Not Acceptable’, 407 => ‘Proxy Authentication Required’, 408 => ‘Request Timeout’, 409 => ‘Conflict’, 410 => ‘Gone’, 411 => ‘Length Required’, 412 => ‘Precondition Failed’, 413 => ‘Request Entity Too Large’, 414 => ‘Request-URI Too Long’, 415 => ‘Unsupported Media Type’, 416 => ‘Requested Range Not Satisfiable’, 417 => ‘Expectation Failed’, 500 => ‘Internal Server Error’, 501 => ‘Not Implemented’, 502 => ‘Bad Gateway’, 503 => ‘Service Unavailable’, 504 => ‘Gateway Timeout’, 505 => ‘HTTP Version Not Supported’ ); if ($code == ” OR ! is_numeric($code)) { show_error(‘Status codes must be numeric’, 500); } if (isset($stati[$code]) AND $text == ”) { $text = $stati[$code]; } if ($text == ”) { show_error(‘No status text available. Please check your status code number or … Continue reading

Posted in Web Development | Tagged , , , , | Leave a comment

Fake Sendmail for Mac (linux)

When developing in PHP perhaps you need to set up a sendmail that just outputs things to text. No need to setup delivery via SMTP. Just create an executable ruby script somewhere, for example: /usr/bin/fake-sendmail.sh with following content: $ touch /usr/bin/fake-sendmail.sh # make it executable (will require root priv.) $ chmod +x /usr/bin/fake-sendmail.sh #!/usr/bin/ruby path = “/tmp/fake-mailer” Dir.mkdir(path) if !File.exists?(path) File.open(“#{path}/#{Time.now.to_i}.txt”, “w”) do |f| f.puts ARGV.inspect $stdin.each_line { |line| f.puts line } end Then edit php.ini sendmail_path = /usr/bin/fake-sendmail.sh props to dan for the script Update I changed one line to use a micro-time format because I was having some trouble with a very fast sending script overwriting some of the existing e-mail files. So, here is the new line to insert: File.open(“#{path}/#{(Time.now.to_f.to_s.gsub(“.”,”")+’00000000′)[0..14]}.eml”, “w”) do |f| Do you need fake sendmail for windows? Check out Byron’s fake sendmail for windows.

Posted in Tech Tips, Web Development | Tagged , , , , | 1 Comment

Heredocs and Nowdocs in PHP

A here document (also called a here-document, a heredoc, a here-string or a here-script) is a way of specifying a string literal in command line shells including all the Unix shells (sh, csh, ksh, Bash and zsh) and the Windows PowerShell and in programming or scripting languages such as Perl, PHP, Python and Ruby. It preserves the line breaks and other whitespace (including indentation) in the text. Some languages allow variable substitution and command substitution inside the string. The general syntax is << followed by a delimiting identifier, followed, starting on the next line, by the text to be quoted, and then closed by the same identifier on its own line. Under the Unix shells, here documents are generally used as a way of providing input to commands. from Wikipedia Example Heredoc Syntax <?php $str = <<<EOD Example of string spanning multiple lines using heredoc syntax. EOD; /* More complex example, with variables. */ class foo { var $foo; var $bar; function foo() { $this->foo = ’Foo’; $this->bar = array(‘Bar1′, ’Bar2′, ’Bar3′); } } $foo = new foo(); $name = ’MyName’; echo <<<EOT My name is ”$name”. I am printing some $foo->foo. Now, I am printing some {$foo->bar[1]}. This should print a capital ’A’: \x41 EOT; ?> NowDocs Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. It shares some features in common with the SGML <![CDATA[ ]]> construct, in that it declares a block of text which is not for parsing. A nowdoc is identified with the same <<< seqeuence used for heredocs, but the identifier which follows is enclosed in … Continue reading

Posted in Tech Tips, Web Development | Tagged | Leave a comment

The PHP Object Expands in PHP5

Starting with PHP 5, the object model was rewritten to allow for better performance and more features. This was a major change from PHP 4. PHP 5 has a full object model. Among the features in PHP 5 are the inclusions of visibility, abstract and final classes and methods, additional magic methods, interfaces, cloning and typehinting. PHP treats objects in the same way as references or handles, meaning that each variable contains an object reference rather than a copy of the entire object. See Objects and References from php manual

Posted in Tech Tips, Web Development | Tagged , | Leave a comment

Good Practices in PHP

Here are a few tips for those of you who’d like to write good code in PHP: Set up a Development Server Set up a development server or sandbox. Don’t write, test, or develop code on a production server. If you are a *nix user, you probably already have a LAMP environment on your own computer. If you are a Windows user, try XAMPP or WAMPSERVER (personal favorite). If you are on mac, try MAMP. As you develop your PHP, you will need to be learning about the environment which it runs in, and the settings that will affect your code and/or application. This is a journey, so don’t expect to master it all at once. You will get into things like virtual hosts, .htaccess files, rewrite rules, and file permissions. Turn on Error Reporting At least, on your development server. On your production site, turn off displaying errors, but have them sent to a file. Check this file periodically as it will show you what unexpected things are happening in your code. Do’s and Don’t’s Don’t use short codes. They take longer to type, but PHP will be moving away from them in future versions. Also, the <? syntax can be mistaken for XML. Examples of short codes include <? instead of <?php, and also the syntax <?= $var ?> which is the easy way of writing <?php echo $var; ?> Do use comments and document your code. Don’t use a closing ?> at the end of your PHP files. … Continue reading

Posted in Tech Opinion, Tech Tips, Web Development | Tagged , | Leave a comment

Complete list of built-in PHP functions

Phar PharData PharException PharFileInfo abs acos acosh addcslashes addslashes aggregate aggregate_info aggregate_methods aggregate_methods_by_list aggregate_methods_by_regexp aggregate_properties aggregate_properties_by_list aggregate_properties_by_regexp aggregation_info apache_child_terminate apache_get_modules apache_get_version apache_getenv apache_lookup_uri apache_note apache_request_headers apache_reset_timeout apache_response_headers apache_setenv apc_add apc_cache_info apc_clear_cache apc_compile_file apc_define_constants apc_delete apc_fetch apc_load_constants apc_sma_info apc_store apd_breakpoint apd_callstack apd_clunk apd_continue apd_croak apd_dump_function_table apd_dump_persistent_resources apd_dump_regular_resources apd_echo apd_get_active_symbols apd_set_pprof_trace apd_set_session apd_set_session_trace apd_set_session_trace_socket array array_change_key_case array_chunk array_combine array_count_values array_diff array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill array_fill_keys array_filter array_flip array_intersect array_intersect_assoc array_intersect_key array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map array_merge array_merge_recursive array_multisort array_pad array_pop array_product array_push array_rand array_reduce array_reverse array_search array_shift array_slice array_splice array_sum array_udiff array_udiff_assoc array_udiff_uassoc array_uintersect array_uintersect_assoc array_uintersect_uassoc array_unique array_unshift array_values array_walk array_walk_recursive arrayaccess arrayiterator arrayobject arsort ascii2ebcdic asin asinh asort assert assert_options atan atan2 atanh audioproperties badfunctioncallexception badmethodcallexception base64_decode base64_encode base_convert basename bbcode_add_element bbcode_add_smiley bbcode_create bbcode_destroy bbcode_parse bbcode_set_arg_parser bbcode_set_flags bcadd bccomp bcdiv bcmod bcmul bcompiler_load bcompiler_load_exe bcompiler_parse_class bcompiler_read bcompiler_write_class bcompiler_write_constant bcompiler_write_exe_footer bcompiler_write_file bcompiler_write_footer bcompiler_write_function bcompiler_write_functions_from_file bcompiler_write_header bcompiler_write_included_filename bcpow bcpowmod bcscale bcsqrt bcsub bin2hex bind_textdomain_codeset bindec bindtextdomain bumpValue bzclose bzcompress bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite cachingiterator cal_days_in_month cal_from_jd cal_info cal_to_jd calcul_hmac calculhmac call_user_func call_user_func_array call_user_method call_user_method_array ceil chdir checkdate checkdnsrr chgrp chmod chop chown chr chroot chunk_split class_exists class_implements class_parents classkit_import classkit_method_add classkit_method_copy classkit_method_redefine classkit_method_remove classkit_method_rename clearstatcache closedir closelog collator com com_addref com_create_guid com_event_sink com_get com_get_active_object com_invoke com_isenum com_load com_load_typelib com_message_pump com_print_typeinfo com_propget com_propput com_propset com_release com_set compact connection_aborted connection_status connection_timeout constant construct convert_cyr_string convert_uudecode convert_uuencode copy cos cosh count count_chars countable counter_bump counter_bump_value counter_create counter_get counter_get_meta counter_get_named counter_get_value counter_reset counter_reset_value crack_check crack_closedict crack_getlastmessage crack_opendict crc32 create_function crypt ctype_alnum ctype_alpha … Continue reading

Posted in Web Development | Tagged | Leave a comment