Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 80/1708 | < Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >

  • Why is there no facility to overload static properties in PHP?

    - by Jon
    Intro PHP allows you to overload method calls and property accesses by declaring magic methods in classes. This enables code such as: class Foo { public function __get($name) { return 42; } } $foo = new Foo; echo $foo->missingProperty; // prints "42" Apart from overloading instance properties and methods, since PHP 5.3.0 we can also overload static methods calls by overriding the magic method __callStatic. Something missing What is conspicuously missing from the available functionality is the ability to overload static properties, for example: echo Foo::$missingProperty; // fatal error: access to undeclared static property This limitation is clearly documented: Property overloading only works in object context. These magic methods will not be triggered in static context. Therefore these methods should not be declared static. As of PHP 5.3.0, a warning is issued if one of the magic overloading methods is declared static. But why? My questions are: Is there a technical reason that this functionality is not currently supported? Or perhaps a (shudder) political reason? Have there been any aborted attempts to add this functionality in the past? Most importantly, the question is not "how can I have dynamic static properties in userland PHP?". That said, if you know of an especially cute implementation based on __callStatic that you want to share then by all means do so.

    Read the article

  • Is it bad practice to output from within a function?

    - by Nick
    For example, should I be doing something like: <?php function output_message($message,$type='success') { ?> <p class="<?php echo $type; ?>"><?php echo $message; ?></p> <?php } output_message('There were some errors processing your request','error'); ?> or <?php function output_message($message,$type='success') { ob_start(); ?> <p class="<?php echo $type; ?>"><?php echo $message; ?></p> <?php return ob_get_clean(); } echo output_message('There were some errors processing your request','error'); ?> I understand they both achieve the same end result, but are there benefits doing one way over the other? Or does it not even matter?

    Read the article

  • configuration issue with respect to .htaccess file on ubuntu

    - by Registered User
    I am building an application tshirtshop I have following configuration in /etc/apache2/sites-enabled/tshirtshop <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/tshirtshop <Directory /var/www/tshirtshop> Options Indexes FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> and following in .htaccess file in location /var/www/tshirtshop/.htaccess <IfModule mod_rewrite.c> # Enable mod_rewrite RewriteEngine On # Specify the folder in which the application resides. # Use / if the application is in the root. RewriteBase /tshirtshop #RewriteBase / # Rewrite to correct domain to avoid canonicalization problems # RewriteCond %{HTTP_HOST} !^www\.example\.com # RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] # Rewrite URLs ending in /index.php or /index.html to / RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L] # Rewrite category pages RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2&Page=$3 [L] RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2 [L] # Rewrite department pages RewriteRule ^.*-d([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&Page=$2 [L] RewriteRule ^.*-d([0-9]+)/?$ index.php?DepartmentId=$1 [L] # Rewrite subpages of the home page RewriteRule ^page-([0-9]+)/?$ index.php?Page=$1 [L] # Rewrite product details pages RewriteRule ^.*-p([0-9]+)/?$ index.php?ProductId=$1 [L] </IfModule> the site is working on localhost and is working as if there is no .htaccess rule specified i.e. if I were to view a page as http://localhost/tshirtshop/nature-d2 then I get a 404 Error but if I view the same page as http://localhost/tshirtshop/index.php?DepartmentId=2 then I can view it. sudo apache2ctl -M Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) php5_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) status_module (shared) Syntax OK What is the mistake if any one can point out in above configuration, or else I need to check any thing else?

    Read the article

  • What and all the areas of Linux a PHP developer should know about? (Like just commands of it or something advanced)

    - by droidsites
    I've developed a website using PHP but I implemented it on Windows OS and hosted it on Windows server. I just searched the PHP job market to know the on-going technology requirement and to keep my knowledge up-to-date accordingly with the job market. I see more are asking for LAMP stack. I understand the sort of skills required for a developer in PHP and MySQL. But coming to the Linux and Apache what kind of the skills exactly companies expect from a developer? On what should I be focusing in case of Linux, Apache whilst developing my website using these LAMP stack? I am going to develop a new website and want it to be using LAMP. But I want to know what difference it makes? Why LAMP stack got more demand in the job market compared to WAMP ? Edit: Sorry I thought my question is creating confusion ... so I put my question in different words as What and all the areas of a Linux a PHP developer should know about? (Like just commands of it or something advanced) Note: I am Linux newbie

    Read the article

  • Trying to move away from PHP/Yii: RoR, Python/Django or ASP.NET MVC? Your opinions please [closed]

    - by Örs
    I have a CS degree and I've been working as a web developer (front & backend) for about 2 years now. I've been working with PHP mostly because it was easy to pick up and find a job, but I've grown to dislike the language and want to try something new, and possibly get a better paying job. That last point is especially important because in my area (Romania/Eastern Europe) PHP jobs are mostly for people fresh out of college/high school, hence the pay is rather low. I've been working with the Yii framework which, if I understand correctly, borrows a lot from Ruby on Rails (convention over configuration, MVC, Active Record, scaffolding). Other than PHP I only know curly-brace languages (C/C++/Java) and bash so Python/Ruby might be a bit challenging. On the other hand I've been using Linux (with vim and recently Sublime Text 2) for almost 4 years now so Windows and a lack of a terminal would have its downsides as well. I'm leaning towards Python/Ruby because of my *nix bias (plus both look like fun), but I've heard great things about ASP.NET MVC as well. Any suggestions? PS: I think there are more jobs in ASP.NET around here, but that's not necessarily a plus, because there are a lot of CS graduates as well. tl;dr: Romanian PHP/Yii developer trying to move to Python/Django or Ruby/Rails or C#/ASP.NET MVC. Suggestions?

    Read the article

  • What and all the areas of a Linux a PHP developer should know about? (Like just commands of it or something advanced)

    - by droidsites
    I've developed a website using PHP but I implemented it on Windows OS and hosted it on Windows server. I just searched the PHP job market to know the on-going technology requirement and to keep my knowledge up-to-date accordingly with the job market. I see more are asking for LAMP stack. I understand the sort of skills required for a developer in PHP and MySQL. But coming to the Linux and Apache what kind of the skills exactly companies expect from a developer? On what should I be focusing in case of Linux, Apache whilst developing my website using these LAMP stack? I am going to develop a new website and want it to be using LAMP. But I want to know what difference it makes? Why LAMP stack got more demand in the job market compared to WAMP ? Edit: Sorry I thought my question is creating confusion ... so I put my question in different words as What and all the areas of a Linux a PHP developer should know about? (Like just commands of it or something advanced) Note: I am Linux newbie

    Read the article

  • How can I make my PHP development environment more efficient?

    - by pixel
    I want to start a home-brew pet project in PHP. I've spent some time in my life developing in PHP and I've always felt it was hard to organize the development environment efficiently. In my previous PHP work, I've used a windows desktop machine and a linux server for development. This configuration had it's advantages: it's easy to configure Apache (and it's modules)/PHP/MySql on a linux box, and, at the time, this configuration was the same like on production server. However, I never successfully set up a debug connection between my Eclipse install and X-debug on server. Transferring files from my local workspace to the server was also very annoying (either ftp or Bazaar script moving files from repository to web root). For my new setup, I'm considering installing everything on my local machine. I'm afraid that it will slow down workstation performance (LAMP + Eclipse), and that compatibility problems will kick-in. What would you recommend? Should I develop using two separate machines? On one? Do you have experience using one of above configurations in your work?

    Read the article

  • How can I make my PHP development environment more efficient?

    - by pixel
    I want to start a home-brew pet project in PHP. I've spent some time in my life developing in PHP and I've always felt it was hard to organize the development environment efficiently. In my previous PHP work, I've used a windows desktop machine and a linux server for development. This configuration had it's advantages: it's easy to configure Apache (and it's modules)/PHP/MySql on a linux box, and, at the time, this configuration was the same like on production server. However, I never successfully set up a debug connection between my Eclipse install and X-debug on server. Transferring files from my local workspace to the server was also very annoying (either ftp or Bazaar script moving files from repository to web root). For my new setup, I'm considering installing everything on my local machine. I'm afraid that it will slow down workstation performance (LAMP + Eclipse), and that compatibility problems will kick-in. What would you recommend? Should I develop using two separate machines? On one? Do you have experience using one of above configurations in your work?

    Read the article

  • Suhosin per-URL exceptions?

    - by STATUS_ACCESS_DENIED
    I am using SimpleID as my OpenID provider and it turns out that if I log on via pages like those on StackExchange, one of the parameters of the GET request gets dropped by Suhosin. The name of the variable is s and I presume it's responsible for the "return to URL" part after login. All of this is not a problem as long as I am already logged into SimpleID from before. However, as soon as the site on which I want to log in via OpenID ends up at the login screen of SimpleID, the redirect back to the site I came from does not work anymore due to the dropped variable. Is there a method to configure either on a per-virtual-host or per-URL basis to ignore the maximum length for GET requests with a parameter s exceeding the (globally) set limit? I'm using Apache 2.2, so I was wondering whether a mechanism similar to setting the PHP ini variables from within the server configuration exists for Suhosin.

    Read the article

  • Sorting a multidimensional array in objective-c

    - by Zen_silence
    Hello, I'm trying to sort a multidimensional array in objective-c i know that i can sort a single dimensional array using the line of code below: NSArray *sortedArray = [someArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; I can't seem to figure out how to sort a 2D array like the one below: ( ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY") ); If someone could provide me code that would sort the array by SOME_CATEGORY it would be of great help to me. Thanks, Zen_Silence

    Read the article

  • Java HashSet<Integer> to int array

    - by jackweeden
    I've got a HashSet with a bunch of (you guessed it) integers in it. I want to turn it into an array, but calling hashset.toArray(); returns an array of Object type. This is fine, but is there a better way to cast it to an array of int, other than iterating through every element manually? A method I want to pass it to void doSomething(int[] arr) Won't accept the Object[] array, even if I try casting it like doSomething((int[]) hashSet.toArray());

    Read the article

  • Perl, array referencing

    - by Mike
    Consider this Perl code my @a=[[1]]; print $a[0][0] . "\n"; **output** ARRAY(0x229e8) Why does it print an Array instead of 1? I would have expected @a to create an array of size 1 with a reference to a second array containing only one element, 1

    Read the article

  • Grouping php array items based on user and created time

    - by Jim
    This is an array of objects showing a user uploading photos: Array ( [12] => stdClass Object ( [type] => photo [created] => 2010-05-14 23:36:41 [user] => stdClass Object ( [id] => 760 [username] => mrsmith ) [photo] => stdClass Object ( [id] => 4181 ) ) [44] => stdClass Object ( [type] => photo [created] => 2010-05-14 23:37:15 [user] => stdClass Object ( [id] => 760 [username] => mrsmith ) [photo] => stdClass Object ( [id] => 4180 ) ) ) However instead of showing: mr smith uploaded one photo mr smith uploaded one photo I'd like to display: mr smith uploaded two photos by grouping similar items, grouping by user ID and them having added them within, let's say 15 minutes of each other. So I'd like to get the array in this sort of shape: Array ( [12] => stdClass Object ( [type] => photo [created] => 2010-05-14 23:36:41 [user] => stdClass Object ( [id] => 760 [username] => mrsmith ) [photos] => Array ( [0] => stdClass Object ( [id] => 4181 ) [1] => stdClass Object ( [id] => 4180 ) ) ) ) preserving the first item of the group and it's created time, and supplementing it with any other groupable photos and then unsetting any items that were grouped (so the final array doesn't have key 44 anymore as it was grouped in with 12). The array contains other actions than just photos, hence the original keys of 12 and 44. I just can't figure out a way to do this efficiently. I used to use MySQL and PHP to do this but am trying to just use pure PHP for caching reasons. Can anyone shed any insights? I thought about going through each item and seeing if I can group it with the previous one in the array but the previous one might not necessarily be relevant or even a photo. I've got total brain freeze :(

    Read the article

  • php array filter

    - by benmsia
    Hi i would like to filter array in php. for example $a = ARRAY('a', 'b', 'c', 'd', 'e'); $b = ARRAY('c', 'd'); $a will be filtered by values in array $b and result is ['a', 'b', 'e'] may I know how to do it in php? Thank you.

    Read the article

  • list or container O(1)-ish insertion/deletion performance, with array semantics

    - by Chris Kaminski
    I'm looking for a collection that offers list semantics, but also allows array semantics. Say I have a list with the following items: apple orange carrot pear then my container array would: container[0] == apple container[1] == orangle container[2] == carrot Then say I delete the orange element: container[0] == apple container[1] == carrot I don't particularly care if sort order is maintained, I'd just like the array values to function as accelerators to the list items, and I want to collapse gaps in the array without having to do an explicit resizing.

    Read the article

  • Using a array variable in a foreach loop

    - by Jess McKenzie
    I am having an issue trying to work out how to use a function variable in a foreach loop so that I can do the following but its not working. $var = array(7) { [0]=> array(3) { ["listingId"]=> int(532712629) } [1]=> array(3) { ["listingId"]=> int(532712202) } Works but not right: foreach($var as $varr) { var_dump($varr['id']); { Goal - Having the array variable as the foreach value foreach($var['id'] as $item) { if($item === $foo) { } }

    Read the article

  • declare or convert a string to array format

    - by Jamex
    Hi, How to convert a string format into an array format? I have a string, $string = 'abcde' I want to convert it to a 1 element array $string[0] = 'abcde' Is there a built in function for this task?? or the shortest way is to $string = 'abcde'; $array[0] = $string; $string = $array; TIA

    Read the article

  • how do I convert a php array of names and coordinates to a javascript array for google map points?

    - by princyp
    I have a php array that has a bunch of data that I need but specifically I need just the name and longitude and latitude from each item in the array so that I can display points on a google map. The google map array needs to look like this in the end var points = [ ['test name', 37.331689, -122.030731, 4] ['test name 2', 37.331689, -122.030731, 4] ]; What is the best way to put my php data into a js array?

    Read the article

  • Generate navigation from a multi-dimensional array

    - by rg88
    The question: How do I generate navigation, allowing for applying different classes to different sub-items, from a multi-dimensional array? Here is how I was doing it before I had any need for multi-level navigation: Home Pics About and was generated by calling nav(): function nav(){ $links = array( "Home" => "home.php", "Pics" => "pics.php", "About" => "about.php" ); $base = basename($_SERVER['PHP_SELF']); foreach($nav as $k => $v){ echo buildLinks($k, $v, $base); } } Here is buildLinks(): function buildLinks($name, $page, $selected){ if($selected == $page){ $theLink = "<li class=\"selected\"><a href=\"$page\">$name</a></li>\n"; } else { $thelink = "<li><a href=\"$page\">$name</a></li>\n"; } return $thelink; } My question, again: how would I achieve the following nav (and notice that the visible sub navigation elements are only present when on that specific page): Home something1 something2 Pics About and... Home Pics people places About What I've tried From looking at it it would seem that some iterator in the SPL would be a good fit for this but I'm not sure how to approach this. I have played around with RecursiveIteratorIterator but I'm not sure how to apply a different style to only the sub menu items and also how to only show these items if you are on the correct page. I built this array to test with but don't know how to work with the submenu1 items individually: $nav = array( array( "Home" => "home.php", "submenu1" => array( "something1"=>"something1.php", "something2" => "something2.php") ), array("Pics" => "pics.php"), array("About" => "about.php") ); The following will print out the lot in order but how do I apply, say a class name to the submenu1 items or only show them when the person is on, say, the "Home" page? $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($nav)); foreach($iterator as $key=>$value) { echo $key.' -- '.$value.'<br />'; }

    Read the article

  • Getting all database entries into organized array

    - by Industrial
    Hi everyone, I have just made the update/add/delete part for the "Closure table" way of organizing query hierarchical data that are shown on page 70 in this slideshare: http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back However, I have a bit of an issue getting the full tree back as an multidimensional array from a single query. Here's what I would like to get back: array ( 'topvalue' = array ( 'Subvalue', 'Subvalue2', 'Subvalue3' = array ('Subvalue 1', 'Subvalue 2', 'Subvalue 3' ) ); );

    Read the article

  • sorting array after array_count_values

    - by umermalik
    hi to all! I have an array of products $products = array_count_values($products); now I have an array where $key is product number and $value is how many times I have such a product in the array. I want to sort this new array that product with the least "duplicates" are on the first place, but what ever I use (rsort, krsort,..) i loose product numbers (key). any suggestions? thanks.

    Read the article

  • high tweet status IDs causing failed to open stream errors?

    - by escarp
    Erg. Starting in the past few days high tweet IDs (at least, it appears it's ID related, but I suppose it could be some recent change in the api returns) are breaking my code. At first I tried passing the ID as a string instead of an integer to this function, and I thought this worked, but in reality it was just the process of uploading the file from my end. In short, a php script generates these function calls, and when it does so, they fail. If I download the php file the call is generated into, delete the server copy and re-upload the exact same file without changing it, it works fine. Does anyone know what could be causing this behavior? Below is what I suspect to be the most important part of the individual files that are pulling the errors. Each of the files is named for a status ID (e.g. the below file is named 12058543656.php) <?php require "singlePost.php"; SinglePost(12058543656) ?> Here's the code that writes the above files: $postFileName = $single_post_id.".php"; if(!file_exists($postFileName)){ $created_at_full = date("l, F jS, Y", strtotime($postRow[postdate])-(18000)); $postFileHandle = fopen($postFileName, 'w+'); fwrite($postFileHandle, '<html> <head> <title><?php $thisTITLE = "escarp | A brief poem or short story by '.$authorname.' on '.$created_at_full.'"; echo $thisTITLE;?></title><META NAME="Description" CONTENT="This brief poem or short story, by '.$authorname.', was published on '.$created_at_full.'"> <?php include("head.php");?> To receive other poems or short stories like this one from <a href=http://twitter.com/escarp>escarp</a> on your cellphone, <a href=http://twitter.com/signup>create</a> and/or <a href=http://twitter.com/devices>associate</a> a Twitter account with your cellphone</a>, follow <a href=http://twitter.com/escarp>us</a>, and turn device updates on. <pre><?php require "singlePost.php"; SinglePost("'.$single_post_id.'") ?> </div></div></pre><?php include("foot.php");?> </body> </html>'); fclose($postFileHandle);} $postcounter++; } I can post more if you don't see anything here, but there are several files involved and I'm trying to avoid dumping tons of irrelevant code. Error: Warning: include(head.php) [function.include]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 4 Warning: include(head.php) [function.include]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 4 Warning: include() [function.include]: Failed opening 'head.php' for inclusion (include_path='.:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/') in /f2/escarp/public/12177797583.php on line 4 To receive other poems or short stories like this one from escarp on your cellphone, create and/or associate a Twitter account with your cellphone, follow us, and turn device updates on. Warning: require(singlePost.php) [function.require]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 7 Warning: require(singlePost.php) [function.require]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 7 Fatal error: require() [function.require]: Failed opening required 'singlePost.php' (include_path='.:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/') in /f2/escarp/public/12177797583.php on line 7 <?php function SinglePost($statusID) { require "nicetime.php"; $db = sqlite_open("db.escarp"); $updates = sqlite_query($db, "SELECT * FROM posts WHERE postID = '$statusID'"); $row = sqlite_fetch_array($updates, SQLITE_ASSOC); $id = $row[authorID]; $result = sqlite_query($db, "SELECT * FROM authors WHERE authorID = '$id'"); $row5 = sqlite_fetch_array($result, SQLITE_ASSOC); $created_at_full = date("l, F jS, Y", strtotime($row[postdate])-(18000)); $created_at = nicetime($row[postdate]); if($row5[url]==""){ $authorurl = ''; } else{ /*I'm omitting a few pages of output code and associated regex*/ return; } ?>

    Read the article

  • How to extract data out of a specific PHP array

    - by user77413
    I have a multi-dimensional array that looks like this: The base array is indexed based on category ids from my catalog. $categories[category_id] Each base array has two underlying elements: ['parent_category_id'] ['sort_order'] I want to create a function that allows us to create a list of categories for a given parent_category_id in the correct sort order. Is this possible? Technically it is the same information, but the array is constructed in a weird way to extract that information.

    Read the article

  • How to: compare array with string and create hastags before tweeting

    - by krike
    Let's say I have the following array (which is the returned value of a database query): Array ( [0] => PHP [1] => Webdesign [2] => Wordpress [3] => Drupal [4]) And the following string: Working With Wordpress Shortcodes How can I compare the array with the string to see if the string contains any word stored in the array? (hopefully that made sense to you :d ) When he finds a match (eg: Wordpress) it should create a hashtag like so: Working With #Wordpress Shortcodes

    Read the article

< Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >