Jump to content

Recommended Posts

I'm not sure what to do here... Do I let php do the work or do I let JavaScript do the work with my news feed.

 

Right now I have a pre of...

 

[0] => Array
                (
                    [id] => 1
                    [firstname] => Sam
                    [lastname] => ran
                    [username] => s
                    [industry] =>
                    [stage] =>
                    [companyid] =>
                    [companytag] =>
                    [gender] => 1
                    [accounttyperaw] => 1
                    [accounttype] => d
                    [country] => 230
                    [state] =>
                    [city] => Old
                    [approveddate] => 1307537300
                    [feedid] => 1
                    [feedfirstname] => Sam
                    [feedlastname] => g
                    [feedusername] => g
                    [action_id] => usercountry
                    [details] => 230
                    [display_name] => fjfj
                    [associate_name] => fjjfj
                    [avatar] => /assets/img/avatars/users/jafkfkfkio.png
                    [message] => You have updated your location to United Kingdom.
                )

message is a new array field which I created to just include the message generated by the row.  This is currently generated in PHP.

The problem is that sometimes message would say...  Sam G has updated his location to United Kingdom where Sam G is a link to his profile page.

 

In that case, the [message] section would include a link in the array. [message] => <a href="">Sam G</a> has updated his location to United Kingdom.

 

Should I have the php create the structure like this or should I try and have javascript do it?

kingphillip is right, server response is quicker and does not depend on browser configuration. One question, why are you using <pre> tags for this?

 

I only use pre to show what was in my array in a readable format.  I don't actually use it on my site.

  • 2 weeks later...

There are pros and cons of using either. PHP will work regardless of the browser, PHP will likely be faster (but that doesn't mean it will *seem* faster to the client). This is important, although PHP will be parsed faster, it will not seem that way to the client if you, for example, use AJAX. If you use PHP to change some text on a page based on a value in a cookie, you really think that will be faster than using javascript to do the same thing? Not at all. JS will win in speed just because it is directly parsed by the browser in real time, even if the actual parsing takes longer.

 

So, if you don't mind sacrificing some independence, use Javascript. Then if need be, use PHP as well.

 

Don't forget, using PHP will also put stress on the server. Won't matter to most but when you're dealing with enterprise applications it is extremely important you don't waste resources processing something the browser can process.

Don't forget, using PHP will also put stress on the server. Won't matter to most but when you're dealing with enterprise applications it is extremely important you don't waste resources processing something the browser can process.

 

You have that wrong. I work in an enterprise-level company; first and foremost concern (for this kind of issue) is that the functionality will work for every user, regardless of their browser. This means for any JS solution you would have to provide a PHP solution anyway. There's also a time issue in companies like mine, so if a combined PHP & JS implementation would take too long it simply wouldn't be a requirement (unless specifically requested).

 

Of course performance is an issue, but with internal core processes where the performance would have a large impact.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.