Parse error: syntax error, unexpected ‘[‘ in line unserialize () []

unserialize($obj)[0] this line may cause error in previous version of php < 5.4 because they do not support array dereference you can check http://php.net/manual/en/language.types.array.php What you can do is, change the code to support previous version or update the version of php in hosting server or local server where you hosted your application. Change of […]

Continue reading


Display products in hierarchy using php

<pre> taxonomy_terms_hierarhically_output(0, ‘product_category’); function taxonomy_terms_hierarhically_output($parent_id, $taxonomy) { $termId = isset($_GET[‘cat’])?$_GET[‘cat’]:0; $args = array( ‘parent’ =&gt; $parent_id, ‘hide_empty’ =&gt; false ); $child_terms = get_terms($taxonomy, $args); foreach ($child_terms as $child_term) { $child_term->name; taxonomy_terms_hierarhically_output($child_term->term_id, $taxonomy); } } </pre>

Continue reading


Find Weekdays Range for a particular date in php

$startDatestr = strtotime(‘monday this week’, strtotime(str_replace(‘/’, ‘-‘, $selDate))); $startDate = date(‘Y-m-d’, strtotime(‘monday this week’, $startDatestr)); $endDate = date(‘Y-m-d’, strtotime(‘friday this week’, $startDatestr)); $start = new DateTime($startDate); $end = new DateTime($endDate); $invert = $start > $end; $format = ‘Y-m-d’; $dates = array(); $dates[] = ($start->format($format)); while ($start != $end) { $start->modify(($invert ? ‘-‘ : ‘+’) . […]

Continue reading


How to authenticate using LDAP with config file in PHP

Authenticate using LDAP in PHP login.php <?php require_once ‘config.php’; /** * Created by Alobin Technologies */ if(isset($_POST[‘username’]) && isset($_POST[‘password’])) { $ldapServer = $config[“LDAP_HOST”]; // ldap://alobin.com $ldap = ldap_connect($ldapServer, $config[“LDAP_PORT”]); // LDAP identifier $username = $_POST[‘username’]; // get the username entered by user $password = $_POST[‘password’]; // get the password entered by user $ldaprdn = $config[“LDAP_DOMAIN”].’\\’.$username; […]

Continue reading