php

PHP switch statement variable scope

In PHP, how is variable scope handled in switch statements? For instance, take this hypothetical example: $someVariable = 0; switch($something) { case 1: $someVariable = 1; break; case 2: $someVariable = 2; break; } echo $someVariable; Would this print 0 or 1/2? ...

How to activate a CSS property according to a variation in PHP code or URL direction?

I change the language in my site using PHP arrays and lang?=. When the user clicks a link to change the language of the site I want this link to keep "pressed" or change to a different color, so the user knows in which version of the site he/she is. How can I activate a CSS property in this situation? common.php: <?php session...

Show login form on every page using Zend Form.

Hello there... I cant seem to figure out how to create a flexible sidebar containing and login form (Zend_Form) and various module/controller specific links. The most common solution seems to be using: echo $this->action('login', 'authentication', 'default'); But apperently this isnt the 'best' way? I've read that this apprently tri...

Getting the day for current day in PHP

I want to get the date for current date in php. what i tried is here... echo $x."<br>"; echo date("D",$x)."<br>"; But the output was 21-02-10 Thu It is giving correct date but not the correct day value.Why..? What I want day is the date for monday for the current week which can be generated on any day of the week. so what I did w...

How to implement this feature in PHP?

When accessing member that doesn't exist, automatically creates the object. $obj = new ClassName(); $newObject = $ojb->nothisobject; Is it possible? ...

Many files in one directory?

I develop some PHP project on Linux platform. Are there any disadvantages of putting several thousand images (files) in one directory? This is closed set which won't grow. The alternative would be to separate this files using directory structure based on some ID (this way there would be let's say only 100 in one directory). I ask this q...

I get session and cookie warning when I upload my php code to a server

I get this: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /www/zxq.net/w/e/e/weedcl/htdocs/index.php:3) in /www/zxq.net/w/e/e/weedcl/htdocs/common.php on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at ...

Streaming an external html/txt file into a PHP script and inserting it into a variable to post to the db

I have created a simple WordPress plugin that automatically sets my new sites up with the default settings that are shared across all of them. As part of the install, it creates my Privacy Policy page. However, currently, I'm just inserting "This is the privacy policy page" for the content, since it's just stored in a variable that I se...

Advice on getting started in web design and web applications?

I am an experienced programmer, and I have a few little ideas that I think would work really well as PHP based web applications. I have no problem with learning PHP, mySQL, etc, but I do have a problem with the design of a webpage in itself. I am used to interface design ala Interface Builder and Swing, where there are some clearly defi...

Why can this kind of statement work in PHP?

$user->Phonenumbers[]->phonenumber = '123 123'; $user->Phonenumbers[]->phonenumber = '456 123'; $user->Phonenumbers[]->phonenumber = '123 777'; I've never seen this kind of syntax EDIT This seems more probably a feature,do you guys know how can I implement a feature like this? ...

Php variable is activated when I call it from index file but not from included file?

The code works when I declare $lang like this (at the top of the index file): index.php (with php variable declaration at the top): <?php $lang = 'es'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html> <head> <meta http-equiv...

Make long log data diplayed with PHP easy to read

I have a long log file I am displaying with PHP. Its getting too long for me and I have to use CTRL+F to look at this thing in any way. What is a good way to display this data in a way easy to read? Best way would be using jquery. ...

PHP Fatal error - Undefined function

I realise this is a bit vague but hoping someone might be able to point me in the right direction. This is the error: Fatal error: Call to undefined function print_row() on line 418 Cause by this line: **$something = profile_display_fields($css->id);** In this code: $customcss = get_records_select('user_info_field', '', 'sortorder...

Should I store a serialized object or JOIN tables in PHP/MySQL?

I'm currently building a site that gives a lot of sorting options to the user and I want to build it in a way that it can be scaled without too much headache. Of course there are tradeoffs to both of these techniques, but id like to hear your opinions. 1) Store a serialized json array in a single column. When a new entry is added or re...

How would i Build a mysql query through a set of PHP OOP methods?

I want to be able to do something like this: $table_object->getRows()->where($wer)->or($or)->orderBy('field', 'DESC'); If i were sure that all the methods will be called each time and in that order, then it would be simple and i can return an instance of the object itself on each method call so that the query gets build and finally ex...

How Do I Enter Multiple PHP Values in .htaccess?

Hi, I'm editing the .htaccess file in order to make some overwrites to my php.ini file (I don't have access to it). So far, I've added: php_value max_execution_time 600 php_value error_reporting E_WARNING php_value log_errors Off The application I'm editing for (vTiger CRM) recommends that "error_reporting" is set to "E_WARNING & ~E_...

Will isset() trigger __get and why?

class a { function __get($property){...} } $obj = new a(); var_dump(isset($obj->newproperty)); Seems the answer is nope but why? ...

Mysql not retaining line breaks from Jquery ajax post?

Hey SO, I've got a PHP/Mysql app that lets users post text from a form. When I insert text from an HTML textarea into my mysql table, it's not keeping the carriage returns/line breaks. The text is not stored in the DB as "Hey SO, \n This is a new line". It's stored with white space in the column (exactly like it's typed), but there is ...

have a variable in the value of a class property?

in my class i have some properties. i want some values of these to have another property. but i noticed it wasnt possible. code: $property = "my name is: $this->name"; generated an error. i set the $this->name with the constructor. could you somehow accomplish this? i would like the "my name is: " to be defined in the property and ...

Is there anyway to get the order of the OOP method being called?

For example lets say I have a set of classes and methods to do so: $obj->method1()->method2(); Is there anyway for method1() to know with in itself that its the first method being called or for method2 to know that its the last? Some more details I just want to be able to build a set of these calls so that it either returns an instan...