php

xml and html escaping special characters

i store my article in a xml file, so if i write into it special characters "' xml automatically escapes this characters and when i get(via PHP) the xml content i get something like \". so if i write into xml "hello dude" my html will look like this \"hello dude\" how can i get the xml content like it was initially inserted("hello dude")...

how to get tax percentage based on zipcode

i am building a custom ecommerce system. how do i get the most current tax rates based on the zipcode? i was thinking of just creating a table and listing all the state tax rates but the thing is the info changes yearly and it might be hard to track and update. would their be any apis that i can use? btw im using php the one thing i ne...

Best way to add missing <p> tags to text in HTML while disregarding other tags?

I'm currently writing a function for parsing some HTML and adding tags where necessary. Basically i have a piece of HTML like this: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat, nunc at vestibulum egestas. <script type="c"> #include &lt;stdio.h&gt; #define debug(var) printf(#var &quot; = %d\n&qu...

Validation Layer in MVC pattern

Where is the best place to validate data which will be used by model. For example, think about registration form. We have some data which come from registration form. So where is the best place to verify this data.We should check every data by if statements or special validator class, and this means lots of coding, so i want to learn whe...

how to do only selected folders with a PHP 5 iterator?

I am trying to use the PHP recursive directory iterator to find php and html files in order to list those by date. The code used is as follows: $filelist = array(); $iterator = new RecursiveDirectoryIterator( $this->_jrootpath ); foreach(new RecursiveIteratorIterator($iterator) as $file) { if ( !$file->isDir() ) { if ( preg_...

zf tool behaves weird

On my ubuntu machine when i try to create a controller: zf create action edit events I get the error: Fatal error: Cannot redeclare class Zend_Tool_Project_Provider_Manifest in /usr/share/php/libzend-framework-p hp/Zend/Tool/Project/Provider/Manifest.php on line 69 I have created a symlink to zf.sh to my /usr/bin/zf But go...

before and after, from bad code to good code, open source project examples, php

It's possible to download old source code versions from open source projects. I want to learn from history. Maybe, more people in Stack Overflow want to learn from history too. What open source projects do you know that made a transition from bad php code to good php code? How do you describe the transition (big, fast, easy...)? What c...

How to set values displayed after submit using PEAR QuickForm?

Let's say I've got form like this: $form = new HTML_QuickForm('Novinky'); $defaults = array('text' => ''); $form->setDefaults($defaults); $elements['text'] = $form->addElement('textarea', 'text', 'Text', array('cols'=>55, 'rows'=>10, 'id'=>'text')); $form->addElement('submit','save','Save'); if (isset($_POST[save])) { if ($form->v...

How to get the home directory from a PHP CLI script?

From the command line, I can get the home directory like this: ~/ How can I get the home directory inside my PHP CLI script? #!/usr/bin/php <?php echo realpath(~/); ?> ...

Why www.example.com/index.php/my/path/here is processed by index.php?

Hello. I am just curious, how is feature of apache is called that is directing requests like this www.example.com/index.php/my/path/here to a file index.php? At the first moment, you might think, that it would be correct if this request leads to 404 error page because there is no folder called index.php at the site root dir. BTW, is...

Python vs PHP for Web Service development

Hello, This question is running a danger of being marked as already asked. I've went through similar posts on stackoverflow and other sites and was not able to find an exact answer. I am planning to write a simple web service which will be an interface to a cloud storage such as S3. In addition it will perform various simple validation...

failsafe for networked robot

I have a robot that I'm controlling via a browser. A page with buttons to go forward, reverse, etc is written in PHP hosted on an onboard computer. The PHP is just sending ASCII characters over a serial connection to a microcontroller. Anyway, I need to implement a failsafe so that when the person driving it gets disconnected, the robot ...

Programatically changing hash of a file without corrupting it

Does anyone have any info on changing the hash of a file without corrupting it? I read about appending a null byte to the end of the file, thus changing the MD5 without corrupting it. Anyone have any info? The language I wish to do this in is PHP. Thanks. ...

Why is the corresponding statement not executed even if echo empty($location) prints out 1

echo empty($location); switch($location){ case (empty($location)): expression 1; break; case ($location%10000==0): expression 2; break; case ($location%100==0): expression 3; break; default: expression 4; break; } When I echo empty($location), it prints out 1, why is expression 1 not executed? ...

Large double quotes: best way to add them

I'm trying to wrap text in some big nice double quotes. I looked at this tutorial, but seems a little more complicated than I thought it should be. My gut tells me someone here in SO knows a smarter way. I'm open to anything: CSS, or PHP or Javascript, or Jquery (but preferably not JS/Jquery) ...

Is there a PHPish way of doing webpages with Ruby?

Is there a framework or something out there so that I can develop webpages in Ruby the same way I can as PHP. Something like <html><head></head><body> <?ruby puts '<p> Hello there!</p>' ?> </body></html> The only thing I'm seeing for using Ruby in webpages is huge complex frameworks that is completely different from how PHP works. I...

Any existing pure PHP "make" tools?

Let me elaborate on the question... I have a custom CMS (built on codeigniter FTW) that includes many different types of modules. Every time we have a new project come through the door, it is a variation and amalgamation of a few of the existing modules. Sometimes a project comes through with requirements that are not satisfied ...

how can i detect browser with php or js

how can i detect if the user is not using any of (chrome, firefox or ie) browser with js or php ...

How to open a new window with target='_blank' ? My code doesn't work.

$html=<<<html <tr><td>$i.<a href="offtask.php?taskid=$taskid target='_blank' ">$title</a></td><td>$count</td><td class="nowrap">$locationtext</td></tr> html; echo $html; How to open a new window in the code above? target='_blank' doesn't work. ...

Latest books to learn PHP, Python?

Decided to learn PHP, Python. Lots of topic/books are there, but don't know which are latest/newbie friendly. Need your help.. ...