I'm doing a router, well with routes, part of my learning and wanted to see if my approach worked. Yet this been bothering me recently, see right now I'm adding the routes in an array, then adding them to a main "manager".
So I got (pseudo sample) to this approach
<?php
$paths = array();
$paths[] = new routes_object('PATH',
...
I want to detect multi accounts in a browser game: If a user has more than one account, I want to know this.
For various reasons, I don't want to detect the multi accounts by comparing IPs anymore. Users can share IPs and IPs are easy to change. So this is not a good method.
Instead, I want to detect the accounts using cookies. Do you ...
I get this message when I try to send mail from php with my ISP SMTP:
Warning: mail() [function.mail]: SMTP server response: 504 <bob>: Sender address rejected: need fully-qualified address in B:\testmail.php on line 2
Any ideas?
...
i need to switch between two variables so i am able to serve two variables equally
for example i have
$ad1
$ad2
i want to serve both ads equally using a light method with no database
using random method won't serve both equally
can you please guide me how to achieve this ?
...
Working with PHP for this.
From a given set of items, each with its own weight, I need to automatically calculate the most effective way to package the items into 100 lbs packages (max package weight of 100 lbs is static, but can be changed in the future). A single package cannot exceed the maximum specified.
As an example, I have 5 i...
I saw this today in some PHP code.
$items = $items ?: $this->_handle->result('next', $this->_result, $this);
What is the ?: doing? Is it a Ternary operator without a return true value? A PHP 5.3 thing?
I tried some test code but got syntax errors.
...
Is there a way to use the Google Translate API with PHP (server-side)? Any resources on that matter? I've searched around but i havent found a valid solution.
...
I have a PHP based web page. Using Ajax, I call PHP routines. Is it a better practice to keep each routine on its own separate file. Or would it be better to keep them all in one file and the divide the file using a $_GET variable.
Example:
if($_GET['AjaxFunction'] == 1) {
...
} elseif($_GET['AjaxFunction'] == 2) {
...
} elseif($_G...
I recently started working on a small CMS. I usually develop .NET applications in C#, and I'm very used to commenting my fields and methods. My friend told me earler that having comments in PHP scripts is quite bad, since PHP is dynamic and parsed when requested, so having to parse the comments will take longer.
Does this statement ap...
I'm having some difficulty getting this script to execute properly.
The create_rss function does not create the RSS file when the remote function updateStatus is called.
<?php
define("DB_HOST", "localhost");
define("DB_USER", "user");
define("DB_PASS", "pass");
define("DB_NAME", "db_test");
class updateService
{
function updat...
I have several forms on my website in which fields are dynamically created or altered based on what is altered in previous fields? Is there a good framework for doing this easily?
...
If I have a parent class that is extended by lots and lots of other classes, and I want to make sure the parent class's constructor is ALWAYS run, is it a bad idea to declare the constructor final?
I was thinking of doing something like this:
class ParentClass {
public final function __construct() {
//parent class initial...
Is there a way to add a custom form element to a Magento Adminhtml form without placing the custom element in the lib/Varian folder?
I've tracked down the code that's essentially a Varian_Data_Form_Element_ factory
public function addField($elementId, $type, $config, $after=false)
{
if (isset($this->_types[$type])) {
$class...
Problem: I need to dynamically call a class and a method of that class. The only thing I get is two strings:
$class = "MyClass";
$method = "myMethod";
How can I create an Instance of the class specified in $class and then call a method on that instance specified in $method?
Like:
$instance = new MyClass;
$instance->myMethod();
...
Hello! I am in the process of making my first Wordpress widget, just one that loads in jQuery tweet. So my problem is that the widget editor in the admin screen won't "remember" my values, I'm sure it just has something to do with the variables just not passing onto the _control function. I am new with PHP so would anybody have any advic...
I'm fairly new to OOP in PHP, I've made a couple of basic scripts but nothing impressive. All I've really taken from it is that it would probably be easier just make a collection of functions and include them.
The structure of classes seems to just confuse what was otherwise a simple process. And in collating everything into a class it...
i am new to .php. I would like to know what are all the ways we can create User Controls (How we do it in asp.net). This found with include in php, but i need to pass parameters to it and use those parameters in that php include file.
...
A while back I used a PNG optimisation service called (I think) "smush it". You fed it a weblink and it returned a zip of all the PNG images with their filesizes nicely, well, smushed...
I want to implement a similar optimisation feature as part of my website's image upload process; does anyone know of a pre-existing library (PHP or Pyt...
If I had:
$string = "CamelCase";
I need
"camel_case"
Does PHP offer a function for this purpose?
...
I am using Zend Framework. For a particular form, there is not enough space to show the errors next to the form elements. Instead, I want to be able to display the errors above the form. I imagine I can accomplish this by passing $form->getErrorMessages() to the view but how do I disable error messages from being shown be each element...