php

Visibility of object constants

I found out that object constants in PHP always have public visibility so it is not possible to set them to protected or private like this: <?php class MyClass { protected const constant = "this won't work"; } ?> What's the explanation for this? I can't think of a good reason to force constants to be public. ...

PHP DOM - Problem loading YouTube Embed Code

Hello, I'm trying to do the following: $string = "<object width=\"425\" height=\"350\"> <param name=\"movie\" value=\"http://www.youtube.com/v/1OtdDqF5rnI&amp;autoplay=0\"&gt;&lt;/param&gt; <param name=\"wmode\" value=\"transparent\"></param> <embed src=\"http://www.youtube.com/v/1OtdDqF5rnI...

How to delay ajax query?

I read a lot of questions, but they doesn't working in my case. My situation is: my ajax query to database to insert infromation. But in my web-application user can click on buttons very quick so previous ajax query is not finished, and there is where bugs are appear. All i need to do is a delay between queries, so future queries will do...

foreach array than search in other array

Why this doesn't work? if (array_search((string)$key,$list)) foreach ($head as $index => $key) { if (array_search((string)$key,$list)) { $data[$index] = serialize($data[$index]); $combined[$key] = isset($data[$index]) ? $data[$index] : null; ...

stristr Case-insensitive search PHP

Hi All, Please excuse my noob-iness! I have a $string, and would like to see if it contains any one or more of a group of words, words link c*t, fu*, sl** ETC. So I was thinking I could do: if(stristr("$input", "dirtyword1")) { $input = str_ireplace("$input", "thisWillReplaceDirtyWord"); } elseif(stristr("$input", "dirtyWord1")) { ...

Time tracking like Expert rating tests

Hi Experts, I am trying to create an Online Quiz script like expert rating test on ODesk or Elance. I want to track the time, means how much time have passed and left. I also want to stop the time counter, if the user internet connection is disconnected, so that he can start from where it was disconnected. One last thing how to disabl...

Need help with MySQL query

Hi, I need help with MySQL query. Here is a part of my database: +---------------+ | users | +---------------+ | id |--- | username | | +-----------------+ +---------------------+ | first_name | | |users_in_projects| | regular_posts | | last_name | | +-----------------+ +----...

php shipping charges api

I want to use one api that will calculate shipping charge automatically & return me the price. please give me solution with one example of api which you will give because i dont know how to use it. thank you ...

Zend Framework: Cache render

I want to use Zend_Cache_Frontend_Output to cache certain sections of my page, I have the cache working but can't get the view helper to render into the cache (the cache entry has data but not the view being rendered). Here's my code but can someone tell me the correct method: if (!($this->_outputCache->start('page_'.$this->getReque...

Filter a Simplehtmldom result

Hi! First, sorry for poor title... I'm working to get some text out of another page and I got one step working by narrow down the source but I have trouble narrow it down more. My code: <?php include('simple_html_dom.php'); $html = file_get_html('https://www.*.org/sok/quote=*'); echo "<b>find all div tags with posts id</b><hr>"; fo...

PHP define() doesn't seem to be working with include()

I've been trying my hand at OO PHP, and currently have three files. I have a class_lib.php which, at the moment, just has a databaseServer class, an index.php file and a definitions.php file. I want to put all my sensitive database info into the definitions file. However, when I do, I get an error when trying to connect to the database: ...

Magento catalogCategoryAttributeList SOAP API call doesn't return all attributes

My goal is to get all attributes listed in Catalog -> Attributes -> Manage Attributes Admin Panel section using SOAP API call. When I am calling stub.catalogCategoryAttributeList(sessionId) Note: Java, Apache Axis used to make this call. In php it's related to this call - http://www.magentocommerce.com/wiki/doc/webservices-api/api/c...

PHP single quotes regex

This topic is a remark for http://stackoverflow.com/questions/3510535/php-get-image-src So we have a variable with code inside (only image): $image = "<img src='http://www.gravatar.com/avatar/66ce1f26a725b2e063d128457c20eda1?s=32&amp;d=identicon&amp;r=PG' height='32' width='32' alt=''/>"; How can we get src of this image? We should t...

What are good open source PHP projects for beginners?

I'm looking into freelancing PHP projects on my spare time so I'm revisiting my rusty PHP skills. I believe contributing to an open source project could refresh me quickly. Also, if you have other suggestion please feel free to suggest. Thanks! ...

Generate gradient color from PHP.

Hi all. I want to know how to build a function that give the code of an color and display a gradient of this color. For example: function generate_color(int colorindex) { ....... ....... Generate 10 pale colors of this color. } Please help me ...

filesize from a String

hello! how can i get the "filesize" from a string in php? I put the string in a mysql database as a blob and i need to store the size of the blob. My solution was to create a temp file and put the string into the temp file. now i can get the filesize from the "string". but that solution is not good... greetings ...

Define dynamic JSON-Array

Hey, i've got a new problem. I know how i have to define a static JSON-Array, but now i must make this dynamic so i could add items with a loop. this is the static version: $json = array(array('field' => 'name', 'value' => $name), array('field' => 'nummer', 'value' => $numbers));...

Using Facebook Single Sign-On

Hi i want to built single sign on using with facebook api and secret key. i am using below code in the index.php: <?php define('FACEBOOK_APP_ID', 'myapikey'); define('FACEBOOK_SECRET', 'secretkey'); function get_facebook_cookie($app_id, $application_secret) { $args = array(); parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), ...

Local or Server Based Crawler that Detects the PHP version of a script

I have custom scripts that are were written near the change of php4 and php5 and I am looking to find all of the php4 versions easily so that I can rewrite them so that they work with php5.3. Is there a tool that can perform this on my local machine or the server? ...

How to reduce the length of very long strings?

I have some text which occasionally contains very long strings of characters, which is breaking my CSS. This is an example: http://iapps.smartphonesoft.com/php/software_details.php?id=358281487 whereas this one is fine http://iapps.smartphonesoft.com/php/software_details.php?id=380894729 Is it possible to strip the very long line...