Skip to Content Skip to Menu

How to suppress outputs/echoes when using getField?

  • tuthmosis
  • tuthmosis
  • OFFLINE
  • Posts: 7
  • Thanks: 0
  • Karma: 0
11 years 2 months ago - 11 years 2 months ago #231516 by tuthmosis
Isn't getField a return? Why does it output echoes? Is there a way I can suppress this so it doesn't output echoes? I use the API in a PHP service layer replying to a JS UI WebApp, but the service replies with a json_encode and echoes cause it to break.


Original Subect:

CG API... Major defect !... getField outputs/echos lots of garbage !

Original Message:

Ok it might not be garbage but it should absolutely not be echoing anything as it is met to return values... not echo them !!!!

I use the API in a php service layer replying to a JavaScript UI web application...

Since the services functions replies using json_encode, echoing string before the call to json_encode breaks the entire system...

Is there a was to use getField in non verbose mode ?

Thanks !

Last edit: 11 years 2 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48438
  • Thanks: 8275
  • Karma: 1443
11 years 2 months ago #231527 by krileon
Echoes, prints, var dumps, etc.. always push to the output buffer. This is simply how PHP works. If you want to suppress the output then just use the ob (output buffer) functions, which is what they're designed to do. It is not practical to suppress an entire function, file, etc.. it should be suppressed on a use by use basis. Example as follows.
Code:
ob_start(); $avatar = $cbUser->getField( 'avatar', null, 'html', 'none', 'list' ); ob_end_clean();

Please see the PHP documentation below regarding this.

www.php.net/manual/en/ref.outcontrol.php

I've edited your subject and message to be more accurate and less damaging as it's absolutely false information and may mislead our less experienced userbase.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum